ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
803 stars 54 forks source link

tern_command doesn't like nvm #17

Closed psyrendust closed 11 years ago

psyrendust commented 11 years ago

I've been trying to get tern_command to work with node installed via npm and it doesn't seem to like it. I get the following in the sublime console:

Traceback (most recent call last):
  File "./sublime_plugin.py", line 210, in on_deactivated
  File "./sublime_plugin.py", line 154, in run_timed_function
  File "./sublime_plugin.py", line 209, in <lambda>
  File "./tern.py", line 25, in on_deactivated
  File "./tern.py", line 290, in send_buffer
  File "./tern.py", line 130, in server_port
  File "./tern.py", line 143, in start_server
  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

I've set 'tern_command' to the following in my Preferences.sublime-settings:

"tern_command": [
    "~/.nvm/v0.8.23/bin/node"
]
"tern_command": [
    "/Users/larrygordon/.nvm/v0.8.23/bin/node"
]
"tern_command": [
    "node"
]

Please note that I've also tried the above 3 configurations adding a 2nd item to the list which is a full path to the tern script:

"tern_command": [
    "/Users/larrygordon/.nvm/v0.8.23/bin/node",
    "/Users/larrygordon/Library/Application Support/Sublime Text 2/Packages/tern_for_sublime/node_modules/tern/bin/tern"
]

At the command prompt in iTerm I get the following:

which node
/Users/larrygordon/.nvm/v0.8.23/bin/node

I'm using oh-my-zsh and my .zshrc has the following to source nvm:

[[ -s "$HOME/.nvm/nvm.sh" ]] && . "$HOME/.nvm/nvm.sh"

I can get it to work by excluding tern_command from my Preferences.sublime-settings if I add a symbolic link to node like so:

ln -s /Users/larrygordon/.nvm/v0.8.23/bin/node /usr/local/bin/node
marijnh commented 11 years ago

That's odd. With absolute paths I really see no reason why this should fail. You will need the second argument to point to your bin/tern script (just pointing at node is not enough), but it sounds like you did. Is the error message the same when you use the last setting you showed (full path, both arguments)?

psyrendust commented 11 years ago

Thanks for the super fast response! I've spent the last few hours going back and forth between your plugin and sublime-tern with no luck, until I figured out the problem with the node path issue.

Hm, that's odd. The dual absolute paths seem to be working now. I think it might have been an issue where I didn't restart SBT2 after making the configuration change. It would be nice to be able to tell if the tern server was started successfully through the console vs no message at all. I also double checked to make sure that I don't have a sym link at /usr/local/bin/node. It all looks to be working correctly now. Thanks for your help!

Side question, is there any way to get tern_argument_hints to show up longer than a few seconds or a way to trigger it to show again without having to move the cursor around?

marijnh commented 11 years ago

Doing :call tern#LookupArgumentHints() should cause the hints to show up again. I'm not familiar enough with the way the echo area in vim works to know why the text disappears again.

jeroentbt commented 10 years ago

Just to let you know that I too had to put the full path to node in my tern_command setting. I'm also using nvm.

OSX 10.8.4, Sublime Text 3047