Closed jawshooah closed 9 years ago
I completely forgot about this issue, good catch. It won't break anyone who has it working but it won't catch if people have it out of date.
Reading through Linter
and RubyLinter
it seems like we need to override how executable_path
gets assigned.
or
It looks like 0.15.0 came out in November 6, 2013 which isn't that long ago. We could just stop checking for it but i'd rather work around the issue.
Oh even better. I'm away from my dev machine but if you prepend the version args with -S rubocop
it will work just fine!
Wow, that was damn obvious. Can't believe I didn't think of it. PR incoming!
I just published 1.0.21, it should hit package control in a few hours.
Sorry to trouble you, but I'm still getting this error.
SublimeLinter: rubocop version query: /usr/bin/ruby -S rubocop --version
SublimeLinter: rubocop version: 2.2.3
SublimeLinter: rubocop: (>= 0.15.0) satisfied by 2.2.3
SublimeLinter: rubocop activated: ['/usr/bin/ruby']
The output of the version query in the terminal is like this.
$ /usr/bin/ruby -S rubocop --version
dyld: lazy symbol binding failed: Symbol not found: _rb_str_new_static
Referenced from: /Users/hsluo/.gem/ruby/2.2.3/gems/json-1.8.3/lib/json/ext/parser.bundle
Expected in: flat namespace
dyld: Symbol not found: _rb_str_new_static
Referenced from: /Users/hsluo/.gem/ruby/2.2.3/gems/json-1.8.3/lib/json/ext/parser.bundle
Expected in: flat namespace
I'm on ST3, SublimeLinter v3.5.4, SublimeLinter-rubocop v1.0.24, and chruby. Is it because ST3 doesn't pick the right ruby
executable?
I'd guess that's right. It seems to be using the system ruby and I don't think ~/.gem/ruby
is built with the system ruby's.
From the debug output, /usr/bin
somehow precedes my ruby path in the computed path, while it's not by echoing in the terminal. I have to add it to paths
in the user settings to get it right in Sublime Text.
This section of the docs seems relevant. Particularly this subsection.
@jawshooah you are right! I thought it was irrelevant and skipped it.
After I move the export stuff to ~/.zprofile
, the path in ST3 looks good. Though I have to specify the ruby version at the end to make chruby really update the ruby path. Thank you very much.
I'm having what appears to me the same issue. If I need to open a new issue please let me know. I'm using chruby 0.3.9, ST3, rubocop 0.37.2, and ruby 2.1.3.
Here's what I get from the debug mode:
SublimeLinter: debug mode: on
SublimeLinter: temp directory: /var/folders/w5/nwtzw8qx4_9ffssyntfrbmlm0000gn/T/SublimeLinter3-donquxiote
SublimeLinter: user shell: /bin/zsh
SublimeLinter: computed PATH using /bin/zsh:
/Users/donquxiote/.gem/ruby/2.1.3/bin
/Users/donquxiote/.rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/bin
/Users/donquxiote/.rubies/ruby-2.1.3/bin
/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin
SublimeLinter: ENV['GEM_HOME'] = '/Users/donquxiote/.gem/ruby/2.1.3'
SublimeLinter: rubocop version query: /Users/donquxiote/.rubies/ruby-2.1.3/bin/ruby -S rubocop --version
SublimeLinter: rubocop version: 2.1.3
SublimeLinter: rubocop: (>= 0.34.0) satisfied by 2.1.3
SublimeLinter: rubocop activated: ['/Users/donquxiote/.rubies/ruby-2.1.3/bin/ruby']
SublimeLinter: rubocop: fund_field_legend_steps.rb ['ruby', '-S', 'rubocop', '--format', 'emacs', '--force-exclusion', '--stdin', '/Users/donquxiote/path/to/my/ruby/file.rb']
SublimeLinter:
I added all of my path altering lines from chruby to my ~/.zprofile
like the SublimeLinter documentation says so I know that is in the proper place. When I run the rubocop version query in my terminal here is my output:
$ /Users/donquxiote/.rubies/ruby-2.1.3/bin/ruby -S rubocop --version
0.37.2
Am I missing anything obvious or shouldn't this be showing the right version?
This error is a result of #16.
The linter is grabbing the Ruby version rather than the Rubocop version. This is because
RubyLinter#lookup_executables
checks the first item incmd
for the name of the gem, using the regexr'(?P<gem>.+?)@ruby'
.If there's a match, it extracts the gem name and uses
util.which
to find its path, and finally setsexecutable_path
to[ruby_path, gem_path]
. If there's no match, it just uses[ruby_path]
.Finally,
Linter#get_executable_version
appendsversion_args
toexecutable_path
to obtain version info.In this case,
cmd
isruby -S rubocop --format emacs
, so the regex doesn't find a match in the first argument,executable_path
is set torvm-auto-ruby
, and the final command isrvm-auto-ruby --version
, notrvm-auto-ruby -S rubocop --version
.