Closed mattma closed 10 years ago
Right now the plugin is using node
to run javascript code. We need a config setup to let you specify your executable of choice (jasmine?). I'll hack on this tonight to get this feature in for you if this is the problem. If you're just wanting to run client side javascript, we don't have a good setup for that. I'd recommend @ardcore's https://github.com/ardcore/atom-safe-eval.
If you do have node, but it's still not running, it may be an environment issue. Script relies on the environment variables that Atom loads with. Atom run from a shell is different than Atom run from the icon/Applications menu. Run env
in a bash script from Atom using script to see what I mean.
As for the absolutely useless error message being passed to you, that needs fixing. Since we're using Atom's BufferedProcess we don't have direct access to node's child_process.spawn
which we would need in order to provide more useful error messages in the display window:
child.stderr.on('data', function (data) {
if (/^execvp\(\)/.test(data)) {
console.log('Failed to start child process.');
// Let user know the executable was unavailable
}
// Other logic
});
An alternative for us of course is to check for the existence of the executable first. Not sure how I feel about that, but it may be necessary.
Whoa, wait. I just re-read what you said about the shell script example. Bash doesn't work either?
Well, I re-tested the shell script, ls -las
. it works. :) what happened is, I created a shell file but I did not save it. When i run the script, it shows the green check mark but without the result. After I read your replied, I tried again with saved file, it works as promised.
I do have node
in my system. I just want to test the script plugin, and no specific purpose on running on client or server side. Well, I tried with server side node code, it still could not run. Could you just provide an example that the script plugin could work as it advertised. So that I could have a reference how to use it. Now, i just simply put any console.log code in coffee or plain js, it does not have a result excerpt an Error code execvp(): No such file or directory
every single time.
Maybe it needs a specific file structure?
@mattma I'm able to run the function you posted above and get the appropriate output both with and without saving the file as shown below. However, the issue you're experiencing is probably because you're launching atom from the dock and not via the command line using the atom
command. If you open via the command line all should work properly.
@mattma Where are you running Atom from?
The icon/Applications or from the console?
Yes, from icon.Applications. How could I run from the console? Instruction please.
I am experienced user of Sublime Text, and i think this plugin could essentially be the build tool for atom. :)
@mattma you can launch Atom from your terminal. Open up a terminal window and type atom -h for more information. If it says something like command not found, go to the menu bar Atom > Install Shell Commands
If you install the cli tools:
You can run atom
from the cli. It picks up your environment variables that way, as well as opening the project you're currently in.
Make sure to fully quit Atom first.
I am experienced user of Sublime Text, and i think this plugin could essentially be the build tool for atom. :)
:clap: That would be awesome! We'd probably need a name change for that, but it's becoming clear that people want a unified output pane for running crud.
First, it works as it advertised.
2nd, I do have atom apm installed in my machine. I think I do have atom command available, or I really do not have it.
Anyway, after I tried that, it works great.
Question, can this one run mocha command for testing? can I execute any cli command in there like rm -rf ./filename
? just tried and it did not work. If you need any help, feel free to ping me and i will make a pull.
Yay! Glad that works for you. We're going to update the README to make sure the cli vs. icon running is clear.
Question, can this one run mocha command for testing?
Mocha may be better suited to @tombell's https://github.com/tombell/test-status.
However, I'm currently hacking away on the config settings right now so that you can change it to use your preferred command for each language.
can I execute any cli command in there like rm -rf ./filename?
You can run any cli commands that don't need input using a bash script. Keep in mind however that the current working directory that it's operating from is wherever Atom was opened from.
Hey there, Awesome work there mate! Just wanted to let you know that I also had to dig up this tread to understand why the package wasn't working for me also... Running Atom from the command line did the trick :+1: but it would be good if you could include this in the readme.md indeed. Also, how could one set this up to be able to start from the "icon" just because I am using Alfred to open most of my stuff and it would be great not having to go through the term. Cheers!
@aesarius - Thanks for poking me on this. I'll edit it now.
No worries mate. Sorry to bother but what about starting Atom form Alfred then? How would I go and set-up the env in that case? Through shebang or something like this? Thanks mate.
Alright, updated env suggestion in 655ccfb35e1e4d4c4b15267c8bae9b7d9be8256e.
On to launchctl
. I covered this a bit in #5, but issues/PRs clearly aren't the documentation.
I don't have Alfred, so if this doesn't work let me know.
What you'll want to do is setup launchctl
to use the PATHing from your normal setup. This can either be done programmatically:
launchctl setenv <key> <value>
or in ~/.launchd.conf
:
$ cat ~/.launchd.conf
setenv KEY 'value'
Someone on StackOverflow has a ridiculous solution for changing launchctl as your export vars in bash.
Let me know what you think of these, and feel free to update the README. I'm always happy to review and merge PRs!
Yet another method is setting up launchctl as part of your bash profile:
p=$(launchctl getenv PATH)
launchctl setenv PATH /my/new/path:$p
That would get executed on every single terminal that is opened though, so nevermind that one.
Ok mate. Will have a look at this when I get a sec :+1: Thanks a lot for your answer!
You've truly made me curious. You can also modify your init script:
Yeah ok this is rather interesting! Nice catch :+1:
Adding the stuff I need to ~/.bashrc
seems to work for me in GUI and the terminal, just wanted to share that in case anybody wants to try it.
Still frustrating about the seeming ambiguity of all the options of settings environment variables.
To update the terminal you might need to use source ~/.bashrc
. I used that since I rarely reboot for anything.
@hansrodtang I definitely don't know the best practice here.
Has anyone seen a good discussion on the forums about this?
For now I just add what I need to ~/.bashrc
and add
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
to ~/.bash_profile
in accordance to what I read here and here.
Seems like this is something Atom itself should fix/make more transparent to package developers since a properly equipped environment is essential to any programming tool. Getting GOPATH for Go into Atom with consistent results has been a pain, I'm glad this tweak finally made it work for me.
So I had a similar problem. I'm a mac noob, so this first bit may have been the wrong thing to do...
I had put atom into its own folder inside /Applications; so /Applications/atom/atom.app. Atom ran fine, command-line worked...life seemed happy. When I tried to use this plugin I was getting the above error...checked my path by using plugin to run env...path looked like a real one, etc...
Long story short, I removed atom from it's old location, and reinstalled as /Applications/atom.app. Now all is well :)
I had the same issue in Ubuntu. Here's what I did to get it working:
'runner':
'extensions':
'csx': '/home/user/installs/scriptcs-dev/src/ScriptCs/bin/Release/scriptcs -script'
to your config.json (ctrl shift p, config)
You should now be able to run C# files saved as .csx files by pressing ctrl shif p then type r and hit enter.
@edmulraney For yours, this is actually the case of scriptcs not being a part of atom-script's grammar file. Looks like you have it working in Atom Runner (not this package) though.
@rgbkrk Haha oops, well spotted. Different package completely. I found this thread when searching for a solution to my scriptcs issue so hopefully someone else will find it useful..
I've just worked around this issue on OSX.
The way I solved it was by using the fix-path module to adjust my path when running from the app file.
Hope this helps any other users with this issue.
@jbavari How did you use fix-path for the script plugin? Is there a pull request or branch I can use?
All of the discussion above seems Linux-centred. However, I'm happily running on W10 and I'm not entirely sure how I can start Atom from cmd, or with custom parameters on an icon, so the package would work. Any suggestions?
W10 +1
It seems to work randomly. Even if I run it from the command line.
@oddysee Wrapped up fix-path as an atom package. You should just be able to apm install atom-fix-path
or install it from the settings pane. Thanks @jbavari for the suggestion.
+1 @rgbkrk for
# init.coffee
process.env.PATH = ['/usr/local/bin', process.env.PATH].join(':')
but who knows what PATH
is set to by default? I prefer just being totally explicit and setting my entire PATH
. That way if a binary can't be found, I know precisely which directories need to be added.
# init.coffee
process.env.PATH = [
"/usr/local/bin",
"/usr/bin",
"/bin"
].join(":")
Less is more™
@naomik On Mac at least, PATH
gets set by launchctl. If you want to see what it gets set to on startup, put
alert(process.env.PATH)
in your init.coffee and see what you get back.
@rgbkrk yeah I still prefer to just set what's required. I do the same in my .zshrc
but maybe that's me being overly controlling.
I generally hate relying on defaults because I can never remember what they are (and they're different on a lot of platforms). It's takes more time for me to look up defaults than it does for me to write what I actually need.
Yeah, I prefer to use what's in my bashrc. The problem lies in how Atom is launched (or restarted after an upgrade...) :unamused:
You may use osx-env-sync to solve this problem on OS X for all applications in the proper way.
Windows 7. I just went into MyComputer, chose Advanced System Settings, and pressed the button marked Environment Variables. Path is the top environment variable. Add ";C:\Python" to the end of the path (or the beginning; or whatever your python path is named). This is the environment that will be loaded every time a command prompt is spawned.
window10 I just run c program but script generate some terrible things , I use google to solve it ,but there is nothing so can you help me?
Just to add another solution… there's also the env-from-shell package.
I'm a pc user. I have downloaded atom recently, and want to set it up for Python coding. Though I have already downloaded 'Script' for run codes. but facing a great problem at the time of running . though the whole code is perfect, getting this message "Python is not recognized as an internal or external command". plz help me to solve this.
A workaround for Win10:
cmd /C atom
A side effect: the terminal window stays open.
miromarszal commented 6 days ago
A workaround for Win10:
Right-click on the Atom shortcut Go to "Properties" Replace the path in "Target" with cmd /C atom
A side effect: the terminal window stays open.
Hi. Let us consider this proposal. How about creating a BAT file?..
The command prompt does open,but does not remain open.
Helpful?
I should have thought about this one, works like a charm.
Error Line Number Based runner not available for JavaScript.
If it should exist, add an issue on GitHub, or send your own pull request.
can anyone help me with this issue please ?
Ubuntu 16.04 :confused:
For Ubuntu and Linux Mint.
Hello bhflm.
Just ran into the same problem you had. This might help.
If you installed the flatpack version from software manager Atom won't be able to find node.
Uninstall Atom.
Go to https://atom.io/ and download the .deb version.
Once downloaded double click on the deb download. A popup window will open. Click on install package.
Not only will Atom now recognize the path to node, your install is now less than 1GB (flatpack is 3.4GB)
Workaroud for python3:
If you want to use Python3 by default, you can open Atom Settings, Atom→Preferences→Open Config Folder, and open.atom/packages/script/lib/grammars/python.coffee, Changing python to python3 under 'Selection Based' and 'File Based', saving it.
Nothing specific for conda? I would like to change the init.coffee suitably to startup atom (when launched by icon) in pre-activated conda env. Thank you
how to fix this 'python' is not recognized as an internal or external command, operable program or batch file.
how to fix this 'python' is not recognized as an internal or external command, operable program or batch file.
if you have python installed from official release, you should not have issues. If you are using conda you can open atom from pre-activated cmd
I just installed the script plugin today on the latest atom editor 0.69.
I have a file named
test.js
, I defined a test function like itThen I hit cmd-i, I got an error
Tried in the readme shell script ls example, it did not work for me at all. I am using the script@2.0.2 , is there any special setup to use this plugin? thanks