Today I got another error out of the blue, similar to another ticket but with a different source:
[Errno 2] No such file or directory
Gotta love that. After some investigation, it turns out Sublime Text 2 couldn't find my jshint, even though the formatted command runs just fine if I copy-paste it into my terminal.
From what I can tell, JSHint.sublime-build sets a path to /usr/local/bin. I'm on ArchLinux, whose npm installs jshint to /usr/bin/jshint. Changing that path setting fixed it for me.
Is it possible to stop the plugin from assuming the path and use the user environment $PATH of some kind?
It is unfortunate that we had to hard-code paths within Sublime Text 2. As I recall, pulling the system path in wasn't possible. I will double check this is still the case and hunt for some kind of alternative.
I noticed a similar issue before, when Sublime Text 2 couldn't find my node executable. It seems to maintain an environment of its own, even curl certificates. If this isn't possible, please feel free to close the ticket, although a Troubleshooting section in the README would be appreciated.
I did a brief investigation today.
>>> import os
It appears Sublime Text 2 just decides to replace its sys.path upon launching the Python interpreter. I agree with a lot of author's design decisions, but this is not one of them.
Every time I launch ST2, it "updates" the plugin and replaces my path fix. So, for now, I've created a symlink to jshint on my system in /usr/local/bin.
Thank you for figuring out a workaround. I will update the README for others before closing this. Maybe we can nudge Jon Skinner to support environment variables for all plugins.
Update, found a real fix
I removed the path attribute in JSHint.sublime-build, and relaunched Sublime Text 2.
>>> import os
The plugin runs smoothly after this fix.
According to the Docs (http://docs.sublimetext.info/en/latest/reference/build_systems.html#troubleshooting-build-systems), Sublime Text 2 is meant to restore the PATH variable after it's run. But apparently not for this plugin. This is a potential bug to ST2, but not of my concern for now. :]
Removing path breaks Mac OS X, which may be where the bug is? At any rate, I'll scope path to only apply to Mac OS X to remove it from Linux.
Interesting. Thanks for the heads up.
This certainly looks to be a Mac only thing according to this thread. Thank you very much for sticking through this until a better resolution was found.
Hm, that thread is a year ago. I'm surprised Mac OS X does not have a default environment, or why that could be different when run in Linux, considering it's just a Python call with subprocess module.
I'll nudge in that thread and hope for interest, but I'm not a Mac user so I won't be very helpful there. Thanks.
Removes path from Linux
Limits hard-coded path to jshint to Mac OS X only, since this causes issues in other Linux environments, such as ArchLinux.