如何使Sublime Text 3与rubocop-rspec一起工作(`require':无法加载此类文件错误)

时间:2016-03-11 20:20:43

标签: sublimetext3 sublimelinter rubocop

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

# .rubocop.yml
require: rubocop-rspec

rubocop在终端的命令行上失败,除非我用:

运行它
bundle exec rubocop

但是,我无法让Subocime中的rubocop与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在rubocop命令之前放置bundle exec

1 个答案:

答案 0 :(得分:0)

我发现这是rubocop gem的一个已知问题: 0.38 fails 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