Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SublimeLinter-Rubocop not running even when enabled and rubocop in path

I'm trying to get Rubocop warnings to show as code marks in Sublime Text 3. I'm using SublimeLinter and the SublimeLinter-rubocop package. (The similar RuboCop package does work but doesn't seem to support code markings.)

rubocop is installed and runs from the rbenv shims folder:

$ rubocop response_test.rb
...
1 file inspected, 11 offenses detected

SublimeLinter is using the rbenv shims:

SublimeLinter: computed PATH using /bin/bash:
/Users/andrew/.rbenv/shims
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

The extension is enabled:

...
"linters": {
    "rubocop": {
        "@disable": false,
        "args": [],
        "excludes": []
    },
    ...
}
...

But the warnings don't show and the linter doesn't even appear to run:

reloading settings Packages/User/SublimeLinter.sublime-settings
SublimeLinter: ruby: response_test.rb ['/usr/bin/ruby', '-wc'] 
SublimeLinter: ruby output:
Syntax OK

Is there anything that could account for this? I'm new to Rubocop and Sublime Text so I may have missed something basic.

like image 673
Andrew McKnight Avatar asked Jan 19 '17 23:01

Andrew McKnight


1 Answers

I just had the same problem recently, and fixed it just now. You probably have already figured it out, but here's my solution.

I believe the problem is that your sublime are searching the system original ruby's path/usr/bin/ruby'.

You have to

Firstly, specify the right path for you ruby env (rbenv in my case) in Packages/User/SublimeLinter.sublime-settings as this:

{
    ...
    "paths": {
        "linux": [],
        "osx": [
            "~/.rbenv/shims/"
        ],
        "windows": []
    },
    ...
}

After that close sublime completely and reopen it.

Hope this helps.

like image 163
H. Jiang Avatar answered Nov 13 '22 01:11

H. Jiang