Sublime Forum

Linter executable

#1

Greetings,
I’m trying to install a linter, and the manual states that I should find my linter executable.
The official guide recommends two lines in consol (I assume max terminal?)
> # Mac OS X, Linux
> hash -r
> which linter

but it does not display anything, what should I try?

0 Likes

#2

The command which SOMETHING tells the shell to search the path for an executable named SOMETHING and display it’s location:

tmartin:dart:~> which subl
/usr/local/bin/subl

This particular lookup is also done the first time you try to run SOMETHING so that the shell knows where the thing is that it’s supposed to run. Once that has happened, the location is kept and the next time the same thing is searched for, it just uses the result from that first search.

The command hash -r tells the shell that it should discard that cache of remembered searches, which makes it have to search again. You would do this if you for example installed a new version of something in a different location than where it used to be or if the location has otherwise changed,.

Taken together, the commands you printed above tell the shell to look for some executable named linter, making sure to perform a fresh search just in case, and display the location it was found at.

If those commands are displaying nothing, there are two main reasons:

  1. There is nothing named linter installed on your system
  2. Something named linter is installed, but it’s not in one of the locations in the system PATH, so it can’t be found.

In the first case, the solution would be to install the thing named linter on your system. How you do that depends on your OS and what the thing actually is, so you would have to Google for how to do that.

Also keep in mind that even after you install linter, the above commands may still not display anything, which means that you’ve traded case #1 for case #2.

The fix for case #2 would be to either update the PATH to include the location where linter is installed or move the thing named linter to a place that’s in the path. However unless you know exactly what you’re doing, you shouldn’t move things around, so I would recommend updating the path. You can Google to see how to do that for your OS (MacOS in your case, I would guess).

Note that this requires you to know where the thing named linter is stored, so if you don’t know where that is you’d have to search for it to know where it is. For this reason if you first had to install linter, you should keep a note of where it was installed so that you can perform this step more easily.

2 Likes

#3

Thanks for the quick reply, but the instructions on the github page aren’t very clear about what to do with the $PATH variable.
"In order for htmlhint to be executed by SublimeLinter, you must ensure that its path is available to SublimeLinter. "
I did a find . | grep htmlhint but it shows only something in ./usr/local/lib/node_modules and I doubt sublime would install there, but if that’s true to what file should the $PATH point to?

0 Likes

#4

Sublime doesn’t install anything but itself. Although PackageControl will install packages, it only installs them to the packages folder.

If something is stored in a node_modules folder, it was probably installed via nodejs because it’s a node application. Presumably either you installed it yourself or something tried to do it on your behalf and failed.

I’m far from a nodejs expert (and the Sublime forum is really the best place for questions about it), but your problem sounds like either the node module you’re interested in was not installed globally, or the install location isn’t in your path.

In my experience when you install something globally with npm it automatically sets up the symlinks for you and places them where they’ll be in the path. How it does that is presumably based on the place/manner in which it your node install happened.

On my mac:

tmartin:tmac:~\> which htmlhint
tmartin:tmac:~\> sudo npm install -g htmlhint
Password:
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
/usr/local/bin/htmlhint -> /usr/local/lib/node_modules/htmlhint/bin/htmlhint
/usr/local/lib
`-- htmlhint@0.9.13 
  +-- async@1.4.2 
  +-- colors@1.0.3 
  +-- commander@2.6.0 
  +-- csslint@0.10.0 
  | `-- parserlib@0.2.5 
  +-- glob@5.0.15 
  | +-- inflight@1.0.6 
  | | `-- wrappy@1.0.2 
  | +-- inherits@2.0.3 
  | +-- minimatch@3.0.4 
  | | `-- brace-expansion@1.1.8 
  | |   +-- balanced-match@1.0.0 
  | |   `-- concat-map@0.0.1 
  | +-- once@1.4.0 
  | `-- path-is-absolute@1.0.1 
  +-- jshint@2.8.0 
  | +-- cli@0.6.6 
  | | `-- glob@3.2.11 
  | |   `-- minimatch@0.3.0 
  | |     +-- lru-cache@2.7.3 
  | |     `-- sigmund@1.0.1 
  | +-- console-browserify@1.1.0 
  | | `-- date-now@0.1.4 
  | +-- exit@0.1.2 
  | +-- htmlparser2@3.8.3 
  | | +-- domelementtype@1.3.0 
  | | +-- domhandler@2.3.0 
  | | +-- domutils@1.5.1 
  | | | `-- dom-serializer@0.1.0 
  | | |   +-- domelementtype@1.1.3 
  | | |   `-- entities@1.1.1 
  | | +-- entities@1.0.0 
  | | `-- readable-stream@1.1.14 
  | |   +-- core-util-is@1.0.2 
  | |   +-- isarray@0.0.1 
  | |   `-- string_decoder@0.10.31 
  | +-- lodash@3.7.0 
  | +-- minimatch@2.0.10 
  | `-- shelljs@0.3.0 
  +-- parse-glob@3.0.4 
  | +-- glob-base@0.3.0 
  | | `-- glob-parent@2.0.0 
  | +-- is-dotfile@1.0.3 
  | +-- is-extglob@1.0.0 
  | `-- is-glob@2.0.1 
  +-- strip-json-comments@1.0.4 
  `-- xml@1.0.0 

tmartin:tmac:~\> which htmlhint
/usr/local/bin/htmlhint

Presumably based on what you said above, the place where your find command found something was /usr/local/lib/node_modules/htmlhint/bin/htmlhint. Above the npm installer created a symlink to that file in /usr/local/bin.

So the first thing I would do would be to try and run /usr/local/bin/htmlhint and see if that works for you. If it does, then your PATH is broken and doesn’t include /usr/local/bin. If it doesn’t, then I would try the install again as above and see if that works for you or not.

Note that on my Mac, my PATH is set as follows:

tmartin:tmac:~\> echo $PATH | sed -e 's/:/\'$'\n/g'
/Library/Frameworks/Python.framework/Versions/3.6/bin
/opt/subversion/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Library/Frameworks/Mono.framework/Versions/Current/Commands
/Users/tmartin/local/bin
/Users/tmartin/android-sdk-macosx/tools
/Users/tmartin/android-sdk-macosx/platform-tools
/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin

My path is fairly customized so yours would be much smaller, but one of those customizations is not to add /usr/local/bin, so I would guess that all things being equal it’s already in your PATH by default in MacOS.

1 Like

#5

Something weird happens, because when I type
$ which linter
nothing happens, but after I did the
$ sudo npm install -g htmlhint then $ which htmlhint gave a reply /usr/local/bin/htmlhint
so I added this path to my $PATH variable (via export)

before:
$ $PATH -bash: /Applications/XAMPP/xamppfiles/bin:/usr/local/php5/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/Applications/XAMPP/bin/:/opt/local/bin:/opt/local/sbin:/Users/5k/.rvm/gems/ruby-head/bin:/Users/5k/.rvm/gems/ruby-head@global/bin:/Users/5k/.rvm/rubies/ruby-head/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/opt/ImageMagick/bin:/Library/TeX/texbin:/usr/local/mysql/bin:/Users/5k/.rvm/bin: No such file or directory

After:
$ export PATH=$PATH:/usr/local/htmlhint $ $PATH -bash: /Applications/XAMPP/xamppfiles/bin:/usr/local/php5/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/Applications/XAMPP/bin/:/opt/local/bin:/opt/local/sbin:/Users/5k/.rvm/gems/ruby-head/bin:/Users/5k/.rvm/gems/ruby-head@global/bin:/Users/5k/.rvm/rubies/ruby-head/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/opt/ImageMagick/bin:/Library/TeX/texbin:/usr/local/mysql/bin:/Users/5k/.rvm/bin:/usr/local/htmlhint: No such file or directory
but still
which linter doesn’t say anything
but I think the bigger problem is that package control install doesn’t find a thing on SublimeLinter-contrib-htmlhint so I think it’s not supported anymore…

0 Likes

#6

which linter doesn’t say anything

There is no “linter” program. The documentation states you should replace “linter” with the name of your linter executable (lots of people miss that part). E.g. which eslint .

1 Like

#7

Ok, that’s wort knowing, but can you confirm you get any results from package control after typing
Sublime​Linter-html-tidy?

0 Likes

#8

My entire experience with Sublime Linter is more or less knowing that it’s a thing and that it exists. So unfortunately I can’t help with problems with that per se.

I can say that I can see it in Package Control just fine. Also PC doesn’t offer you packages to install if you have already installed them, so maybe you did that step already?

For what it’s worth, the GitHub README for that Package looks like it wants to use a different HTML tidy binary than the one you’re referencing above, so you may still have issues either way.

0 Likes

#9

Ok, thanks very much I think it was the $PATH, but the comment about the which command was usefull!

0 Likes