Sublime Forum

No output with Custom Build-System for Neuron on OSX

#1

Hi,

I’m new to sublime text and am trying to get setup to run code in Neuron, a neural simulation environment. Specifically, I’m trying to get output from .hoc files, a file type in Neuron that is executed as an interpreted language. Typically I can run a .hoc file from the command line with:
nrngui filename.hoc
given I’m in the current directory for that file. This will execute the file, show output and leave one in the hoc interpreter within the command line.
In sublime text I’ve created the following build-system file:
{
"shell_cmd": ["nrngui", "$file"],
"selector": "source.Neuron",
"file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)"
}
Whenever I run this I get absolutely no output.

Note: I’ve added syntax highlighting (thank you Jordan Guerguiev on github) and I assumed that is what should be supplied to selector.

0 Likes

#2

shell_cmd should have a string as an argument, not a list of items (cmd works that way). So changing the value of shell_cmd to "nrngui \"$file\"", may work better.

You might want to check the Sublime console (View > Show Console) to see if it’s generating any sort of errors when you run this that might be stopping it from working.

One last thing to note is that Sublime doesn’t directly support interactive programs; it captures output but it doesn’t connect up the input of your program to anything. So if all works properly, your program will run and when the interpeter goes interactive it will essentially hang in the background and you won’t be able to interact with it.

The Terminus package is a good way to run something like this; I have a video available on how to convert a build system to use terminus that may be of help in this regard as well.

0 Likes

#3

Thank you! Changing the value of the shell_cmd to a string argument worked. Is there anyway to keep the command line active in the output? Also, I have another issue. When running nrngui from the command line it will launch an x11 interface, that interface is empty when run from sublime text. Specifically, the windows for the interface appear but there are no buttons, it’s empty, just a white box.

0 Likes

#4

Only by using something like the package I mentioned above; you need to add a couple of extra lines to the sublime-build file to get it to trigger, but then it will behave like a standard build output except also allow input.

I’m not sure offhand what would cause something like that. Perhaps it gets angry about it’s stdin isn’t connected to anything and can’t fully initialize itself? Running it in Terminus may solve the problem if that’s the case.

0 Likes

#5

Thank you again! I was jumping between different task and read over your initial response to quickly. I installed terminus and modified my code and the neuron interface now works, but now another problem has come up. Neuron uses precompiled .mod files, it seems one of these files isn’t getting recognized during the build. Again when I run in the command line I don’t get any issues and the code runs fine with no warning - not sure if that has something to do with not raising certain execute flags. Anyhow, I get the following syntax warning in sublime text:
<stdin>:114: SyntaxWarning: "is not" with a literal. Did you mean "!="?
But this seems unrelated to the problem, because another IDE (coderunner) gives this warning but is able to run the file (trying to move away from coderunner).

0 Likes

#6

Unfortunately I’m not familiar with that tool/language at all. Does it perhaps require some specific environment variables to be set that gives it extra information about what to load?

0 Likes

#7

I’m not sure about the environment variables. It seems sublime text isn’t recognizing files that are called from the current hoc file I’m running. Are the variables from the called file being lost? What’s the difference between Sublime executing a line of code from the command line and running it from osx terminal?

0 Likes

#8

If you’re using shell_cmd, technically none; it asks /bin/bash (on OSX) to execute the command as if you’ve typed it.

Your build system doesn’t have a working_dir key in it, which sets what folder is considered to be the active folder when the command runs (essentially what folder your terminal would be in if you typed the command).

If that’s important, like the files it needs are stored and referenced relative to the file that you’re running, then that might be the issue. You could try setting it to something like "working_dir": "$file_path", to have the current directory always be set to where the file you’re currently editing is stored.

0 Likes

#9

Thank you once again! That did the trick. Before you posted this I got it to work by creating a project from the folder the file I wanted to run was in. I assume when I created a project a "working_dir": got set. This is great, now if I could just figure out where the syntax warning is coming from all will be set. Although, this warning isn’t a critical issue at the moment. Thanks again, for your help getting going.

1 Like