2

我有使用 rubocop 和 sublimelinter 的 Sublime Text 3。但是,当我启用 rubocop-rspec 时:

# .rubocop.yml
require: rubocop-rspec

rubocop 在终端的命令行上失败,除非我使用以下命令运行它:

bundle exec rubocop

但是,我无法让 rubocop 在 Sublime 中与 rubocop-rspec 很好地工作,我在启用调试的 Sublime 控制台中看到了这一点:

SublimeLinter: rubocop output:
/Users/sean/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- /Users/sean/Dropbox/Sean/Sites/tovgdb/rubocop-rspec (LoadError)

有没有办法让 sublimelinter 放在bundle execrubocop 命令之前?

4

1 回答 1

0

我发现这是 rubocop gem 的一个已知问题: 0.38 failed to load rubocop-rspec #2937

我暂时注释掉了导致我的问题的代码,并从早期版本的 gem 中放回了代码:

# ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rubocop-0.38.0/lib/rubocop/config_loader.rb

# Temporary Code copied from earlier version of gem:
Array(hash.delete('require')).each { |r| require(r) }

# Code Commented Out:
# config_dir = File.dirname(path)
# Array(hash.delete('require')).each do |r|
#   require(File.join(config_dir, r))
# end
于 2016-03-12T00:57:20.577 回答