Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env: node: No such file or directory #32

Closed
alexchandel opened this issue Mar 14, 2013 · 23 comments
Closed

env: node: No such file or directory #32

alexchandel opened this issue Mar 14, 2013 · 23 comments

Comments

@alexchandel
Copy link

I am running OSX 10.8.2, Sublime Text 2.0.1, sublime-better-coffeescript v2013.01.26.20.45.16, which I installed with Package Control. I tried the following in a file named script.coffee:

-> "Hello World"

and I obtained:

env: node: No such file or directory

My coffee executable is located at /usr/local/share/npm/bin, the global location for npm when node is installed with brew, so I set "binDir": "/usr/local/share/npm/bin" in the settings.

My node executable is located in /usr/local/bin, but I can't set that, and I think /usr/local/bin is already in my Sublime Text 2 path.

Pressing Option+Shift+C yields Compilation failed in the status bar.

If I run the file with Command+Shift+B, I obtain:

[Errno 2] No such file or directory
[cmd:  [u'coffee', u'/Users/alex/Media/GitHub/sc6-telemetry-code/tel/script.coffee']]
[dir:  /Users/alex/Media/GitHub/sc6-telemetry-code/tel]
[path: /usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
[Finished]

And of course Command+B yields:

[Errno 2] No such file or directory
[cmd:  [u'cake', u'sbuild']]
[dir:  /Users/alex/Media/GitHub/sc6-telemetry-code/tel]
[path: /usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
[Finished]

I don't want to make a Cakefile. I should be able to compile a single source.coffee file into something like source.js.

@alexchandel
Copy link
Author

For what it's worth, I checked and when I run Option+Shift+C, the final command list it passes to Popen is ["coffee", '-b', '-c', u'/Users/alex/Media/GitHub/sc6-telemetry-code/tel/script.coffee'], which fails somehow. If I run this from the Terminal, it succeeds.

@aponxi
Copy link
Collaborator

aponxi commented Mar 15, 2013

Ok I think I know what is messing this up. Several people have been having similar problems... This has to do with the last commit.

@aponxi
Copy link
Collaborator

aponxi commented Mar 15, 2013

The last commit was done for #26

I have just reverted that. Could you please check now?

#30 is also related to this.

@alexchandel
Copy link
Author

I don't think this has anything to do with the last commit, because I'm using the version v2013.01.26.20.45.16, from the Sublime Package Manager. The commit you referred to is almost two months newer. This is a very old issue.

Speaking of the package manager, you should update the version in the Sublime package manager.

@aponxi
Copy link
Collaborator

aponxi commented Mar 22, 2013

Ok I'm looking into this now

@deepfriedmind
Copy link

Seconded. I'm guessing a lot of people use Homebrew to install Node so a fix would be greatly appreciated.

@rockwood
Copy link

+1

@alexchandel
Copy link
Author

i can help you debug, but remember I'm using the old v2013.01.26.20.45.16. I just want to compile a single standalone coffeescript file, no build system.

Also I noticed a bug that may be related. Every time I run the Build:Run command (which displays a failure report), I notice the path has grown by one "/usr/local/bin:". Repeatedly running the command will add dozens of duplicate "/usr/local/bin:" path elements.

@aponxi
Copy link
Collaborator

aponxi commented Mar 22, 2013

@alexchandel Help would be appreciated...

I believe I added ad function like path resolve to get the absolute path to the file... I think there is an issue there since I think all of this started happening after I added that line.

I'm suggesting that the execution of the command is good but resolving the path to the file has problems, hence getting the "no such file/dir" error. I'm open to suggestions about multiple OS compatible path resolve function(s).

@alexchandel
Copy link
Author

Well something is wrong with the path resolution, because it re-appends the path each time. Since we set the binDir variable in a config file, why do we need to find/add the absolute path of the executable every time?

@alexchandel
Copy link
Author

I found a partial hardfix. In CoffeeScript.sublime-build, change the path to

"path": "/usr/local/share/npm/bin:/usr/local/bin:$PATH"

This fixes the Build commands, but does nothing for the Compile command. This tells me the binDir path isn't being added to the Build PATH. Incidentally, the node executable is always picked up because homebrew fortunately installs it to /usr/local/bin; however, you should make a separation binDir variable for the node executable.

Also, I have a lead for you on Compile commands. CompileCommand eventually calls run("coffee", ["-c", "/whatever/script.coffee"]). In run, you create the env variable, which messes up the Popen call. I find that changing

proc = Popen(command, env=env, cwd=cwd, stdout=PIPE, stderr=PIPE)

to

proc = Popen(command, cwd=cwd, stdout=PIPE, stderr=PIPE)

makes that snippet runnable when copypasted into the interpreter. The final call ends up being sp.Popen(['coffee', '-c', u'/whatever/script.coffee'], cwd=None, stdout=sp.PIPE, stderr=sp.PIPE), and this executes fine from the interpreter. Note that it fails when the env=env parameter is also set.

However, and I have no idea why, this completely blows up in Sublime Text. When I run Coffee: Compile File, the console says:

Traceback (most recent call last):
  File "./sublime_plugin.py", line 362, in run_
  File "./CoffeeScript.py", line 101, in run
  File "./CoffeeScript.py", line 32, in run
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Even trimming the call down to just Popen(command) doesn't fix it, although this obviously works fine in the command line. I'm absolutely positive that command == ['coffee', '-c', u'/whatever/script.coffee'], so there must be something wrong in the module environment.

I'm really not sure what the problem is with the Compile commands. If you have a potential solution, I can test it, but I strongly recommend you investigate this bug, as it probably affects everyone who installs coffeescript/node with homebrew.

@jfernandez
Copy link

+1

@alexchandel
Copy link
Author

+1

I persuaded a friend, a recent Sublime Text 2 convert, to try installing CoffeeScript (he first had to install homebrew, then node via homebrew) and sublime-better-coffeescript. He encountered the exact same issue. He'd never used CoffeeScript before (just JS).

This suggests this problem affects everyone who installs node/coffeescript via homebrew.

@aponxi
Copy link
Collaborator

aponxi commented Apr 9, 2013

I hear you guys! I have been busy with a C# project and will fix this as soon as I can take a break from it. In the meantime if you are able to, send a pull request and I would gladly put it in.

Thanks for your interest and I apologize for my absence.

@mihado
Copy link
Contributor

mihado commented Apr 25, 2013

I kinda fixed the problem by symlink the coffee-script modules from npm directory to /usr/local/bin

ln -sv /usr/local/share/npm/lib/node_modules/coffee-script/bin/coffee /usr/local/bin/coffee
ln -sv /usr/local/share/npm/lib/node_modules/coffee-script/bin/cake /usr/local/bin/cake

@alexchandel
Copy link
Author

Hopefully not a permanent fix.

With the current release build, there's now a error: env: node: No such file or directory popup error. Since you use both node and coffee, maybe you should have two binDir variables, one for node and one for coffee? I think there's another ST2 coffeescript plugin that does just that.

aponxi pushed a commit that referenced this issue May 26, 2013
@aponxi
Copy link
Collaborator

aponxi commented May 26, 2013

Should be fixed now with the new settings. Check the envPATH setting out!

@aponxi aponxi closed this as completed May 26, 2013
@zakdances
Copy link

Still can't get this to work. I keep this in my console when I try to enable watch mode:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 255, in on_post_save
    callback.on_post_save(v)
  File "CoffeeScript in /Users/zak/Library/Application Support/Sublime Text 3/Installed Packages/Better CoffeeScript.sublime-package", line 421, in on_post_save
  File "CoffeeScript in /Users/zak/Library/Application Support/Sublime Text 3/Installed Packages/Better CoffeeScript.sublime-package", line 345, in refreshOut
  File "CoffeeScript in /Users/zak/Library/Application Support/Sublime Text 3/Installed Packages/Better CoffeeScript.sublime-package", line 70, in brew
  File "CoffeeScript in /Users/zak/Library/Application Support/Sublime Text 3/Installed Packages/Better CoffeeScript.sublime-package", line 58, in run
  File "X/subprocess.py", line 818, in __init__
  File "X/subprocess.py", line 1416, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: 'coffee'

In my settings I've tried

"envPATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

and both

"binDir": "/usr/local/bin"

and

"binDir": "/usr/bin"

What's the problem here?

@aponxi
Copy link
Collaborator

aponxi commented Aug 16, 2013

The problem is the plugin cannot find coffee executable. This may not be related to the plugin itself, so let's try to debug this.

  • First let's make sure coffee-script is installed on your OS: Try finding coffee-script in your global npm list with npm ls -g | grep coffee which will output something like
logan@host:~$ npm ls -g | grep coffee
├── coffee-script@1.6.3
├─┬ coffeelint@0.5.6
│ ├── coffee-script@1.6.3
├── UNMET DEPENDENCY generator-coffee *
│ │ ├── coffee-script@1.3.3
  • if you would go to terminal and type which coffee it should tell you the path to it:
logan@host:~$ which coffee
/usr/bin/coffee
  • we should make sure the "binDir" in the configuration points to that.

Post your findings and I'll help you debug.

@aponxi aponxi reopened this Aug 16, 2013
@zakdances
Copy link

@aponxi Sorry about the delay. I'll be going through your steps later this evening, so I'll report back soon.

@lavrton
Copy link
Contributor

lavrton commented Aug 24, 2013

Close for now.
@aponxi, please insert info about binDir and which coffee to readme. For example "FAQ" section.

@lavrton lavrton closed this as completed Aug 24, 2013
@zakdances
Copy link

For someone reason my email update didn't show up here. Following Aponxis instructions, it now seems to be working, so thank you @aponxi . It'd be a great addition to the Readme, as lavrton mentions.

@aponxi
Copy link
Collaborator

aponxi commented Aug 24, 2013

You are most welcome @zakdances ! I'm happy to hear that you were able to solve your issue.

@lavrton I will provide more instructions on those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants