Paul Bissex
Paul Bissex

Reputation: 1704

How do I extend the $PATH that Sublime Text 2 uses?

I just installed Sublime-jshint (and the requisite node.js + jshint) but get this error when I try to invoke JSHint from within ST2:

[Errno 2] No such file or directory
[cmd:  [u'jshint', u'PATH-TO-THE-JS-FILE-I-AM-LINTING', u'--reporter', u'/home/cmg/.config/sublime-text-2/Packages/JSHint/reporter.js']]
[dir:  DIR-MY-JS-FILE-IS-IN]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/cmg/bin]
[Finished]

The final item in the given path is in the home dir of my user (cmg), so it's been customized somehow... but I don't recall how, so I don't know how to add the dir I need (~/node_modules/.bin).

I've added it to $PATH in my shell (via both .bashrc and .bash_profile) but ST2 doesn't pick it up.

(I'm on Ubuntu 14.04. All the usable stuff I've found via Google on this subject has been either OS X specific or related to ST's build system).

Upvotes: 0

Views: 160

Answers (2)

MattDMo
MattDMo

Reputation: 102852

Open /etc/profile in Sublime (using sudo) and add the following line at the very bottom:

export PATH=/home/cmg/node_modules/.bin:$PATH

and save the file. Restart completely, and your PATH should be updated.

Upvotes: 0

FichteFoll
FichteFoll

Reputation: 792

Basically, the exec command, which the jshint package uses internally, allows you to set/extend the PATH of the spawned subprocess. (docs)

The package actually uses this path argument on OSX, but has it hardcoded (I am partly guilty of that as I rewrote the command because it was just horrible before). It should allow for a setting to specify the path to your jshint executable, so I suggest you create an issue for that.

I don't know why ST dosn't pick up your PATH from somewhere else since I have very little experience with that.

Upvotes: 1

Related Questions