ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
801 stars 52 forks source link

FileNotFoundError on Win10 x64 and Node.js 4.0.0 #84

Closed gpuberos closed 9 years ago

gpuberos commented 9 years ago

Hello,

Term_for_sublime doesn't work and the popup message (Yes Install Button) appears on each launch.

System

Traceback (most recent call last):
  File "./subprocess.py", line 1112, in _execute_child
FileNotFoundError: [WinError 2] File specified cannot be found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 158, in on_api_ready
    m.plugin_loaded()
  File "C:\Users\Guy-Philippe\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 592, in plugin_loaded
    subprocess.check_output(["npm", "install"], cwd=plugin_dir)
  File "./subprocess.py", line 576, in check_output
  File "./subprocess.py", line 824, in __init__
  File "./subprocess.py", line 1118, in _execute_child
FileNotFoundError: [WinError 2] File specified cannot be found

Thanks by advance for your help.

garthenweb commented 9 years ago

Get the same error with on Windows. Windows 7 (64Bits) Node.js v0.10.39 npm v2.14.3 SublimeText 3 Build 3083

I tried to install tern globally with npm but the issue is still occurring.

marijnh commented 9 years ago

So did you try going to the package directory and running npm install there, as the README asks you to do?

garthenweb commented 9 years ago

Yes, after installing the dependencies by hand into the package folder the popup dose not show up again. So this looks like an use with the install layer.

marijnh commented 9 years ago

Running something like npm or node from a Python process in an arbitrary environment is unfortunately painful and difficult. If you have a specific solution for the problem you found, I'll happily apply it, but, since the README already tells you how to install this and the automatic installation is only a fall-back, I'm not going to spend more energy on making it more robust.

garthenweb commented 9 years ago

I get the problem. Maybe its not required to fix it entirely, but probably it would be possible to fail more graceful. Would it be an option to show an error message when installing failed with a hint to install it by hand?

Personally I come up on my own with the idea to install tern inside of the package. As far as I installed the package via package manager, I did not read the README install section because it was already installed. Probably the hint should become more visible within the readme and should not hide behind the git clone commands.

Would it also be possible to use a globally installed reference in case no version is installed into the package folder? This was my first approach to fix the issue but did not work. I guess some other libraries are working like that.

marijnh commented 9 years ago

There is already such a message, but it sounds like it is somehow not being shown on your system. Can you see if you get any errors in Sublime's ctrl-console when this happens? (You could temporarily movenode_modules` to another name, and restart Sublime to re-trigger the installation attempt.)

garthenweb commented 9 years ago

After submit the "Yes, install." button the following is printed into the console

Traceback (most recent call last):
  File "./subprocess.py", line 1112, in _execute_child
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 158, in on_api_ready
    m.plugin_loaded()
  File "C:\Users\<user>\AppData\Roaming\Sublime Text 3\Packages\tern_for_sublime\tern.py", line 595, in plugin_loaded
    subprocess.check_output(["npm", "install"], cwd=plugin_dir)
  File "./subprocess.py", line 576, in check_output
  File "./subprocess.py", line 824, in __init__
  File "./subprocess.py", line 1118, in _execute_child
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

This seams to be the same error log as provided by the issue creator (except of some German wordings).

marijnh commented 9 years ago

Ah, it can throw FileNotFoundErrors too, who knew. Sometimes more formal specifications about what throws which kind of error would be good to have.

Attached patch widens the types of errors that are caught in this situation, and should give you a sane error message.

garthenweb commented 9 years ago

Thank you! The patch is working well for me.