Vim from terminal can locate package, GVim cannot

Posted on

Problem :

So I’ve been installing Syntastic and JSHint for some Vim JavaScript syntax checking.

which jshint returns /home/myUser/local/bin/jshint

which vim and which gvim return /usr/bin/vim and /usr/bin/gvim` respectively.

If I open a JS file from myUser‘s terminal, Syntastic works fine – :SyntasticInfo returns

Syntastic version: 3.5.0-72
Info for filetype: javascript
Mode: active
Filetype javascript is active
Available checker: jshint
Currently enabled checker: jshint

However, if I open the same file with GVim, JSHint is not loaded.

Syntastic version: 3.5.0-72
Info for filetype: javascript
Mode: active
Filetype javascript is active
Available checker: -
Currently enabled checker: -

This makes sense given that if I run :!which jshint from vim in the terminal, I get a path and if I run it from GVim I get shell returned 1.

I poked around and noticed that JsHint is not loaded in command line Vim if I sudo su root and then run vim. Conversely, JSHint is loaded if I open GVim as my current user gksudo -u uname -l "gvim".

I’m assuming this means that I somehow need to get /home/myUser/local/bin/jshint on my root $PATH, but I don’t know if this is possible or recommended.

Solution :

PATH is not a global shell variable that you should expect to be the same for all users. You could make it so but that would be pointless: if you want some program to be usable by every user, install it as root.

And… root is used for administrative tasks, not actual work (unless you are a sysadmin but you are not), so don’t work as root.

Leave a Reply

Your email address will not be published. Required fields are marked *