0

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).

Paul Bissex
  • 1,611
  • 1
  • 17
  • 22

2 Answers2

1

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.

FichteFoll
  • 663
  • 1
  • 6
  • 12
0

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.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • Thanks. I meant to note in the question -- the dir is on my $PATH in the shell, but ST2 isn't picking it up. – Paul Bissex Sep 23 '14 at 16:55
  • Also -- If I start ST via the `subl` command, it does pick up $PATH from my shell. But I generally launch it via the Unity launcher or Kupfer. – Paul Bissex Sep 23 '14 at 18:29
  • Also settings PATH for desktop shortcut: http://stackoverflow.com/questions/25994666/setting-environment-variables-for-sublime-text-on-osx-desktop/25996724#25996724 – Mikko Ohtamaa Sep 25 '14 at 13:06
  • 1
    @PaulBissex see my edit above. In order to modify the PATH used by GUI apps launched from Unity (or Kupfer, or whichever your favorite launcher is), you'll need to modify the system's PATH. `/etc/profile` is probably the best place to put it, or (I'm going from memory here, I'm not on Ubuntu ATM) you could create a new file in `/etc/profile.d`. You'll need superuser privileges to do that, so just launch Sublime from your favorite terminal emulator using `sudo subl ...`. – MattDMo Sep 25 '14 at 15:21