Skip to content

Assumed use of /usr/local/bin/jshint #21

Closed
Spaxe opened this Issue Apr 11, 2012 · 9 comments

2 participants

@Spaxe
Spaxe commented Apr 11, 2012

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?

@uipoet
Owner
uipoet commented Apr 11, 2012

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.

@Spaxe
Spaxe commented Apr 11, 2012

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.

@Spaxe
Spaxe commented Apr 13, 2012

I did a brief investigation today.

>>> import os
>>> os.environ['PATH']
'/usr/local/bin'

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.

@uipoet
Owner
uipoet commented Apr 13, 2012

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.

@Spaxe
Spaxe commented Apr 13, 2012

Update, found a real fix

I removed the path attribute in JSHint.sublime-build, and relaunched Sublime Text 2.

>>> import os
>>> os.environ['PATH']
'/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/spaxe/.local/bin/:/usr/bin/vendor_perl/'

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. :]

@uipoet
Owner
uipoet commented Apr 13, 2012

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.

@Spaxe
Spaxe commented Apr 13, 2012

Interesting. Thanks for the heads up.

@uipoet
Owner
uipoet commented Apr 13, 2012

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.

@Spaxe
Spaxe commented Apr 13, 2012

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.

@uipoet uipoet pushed a commit that closed this issue Apr 13, 2012
Jamie Hoover ⚔ 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.

Closes #21.
0c1c877
@uipoet uipoet closed this in 0c1c877 Apr 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.