【问题标题】:How to make Sublime Text 3 work with rubocop-rspec (`require': cannot load such file error)如何使 Sublime Text 3 与 rubocop-rspec 一起工作(`require':无法加载此类文件错误)
【发布时间】:2016-06-27 05:30:20
【问题描述】:

我有使用 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 exec 放在 rubocop 命令之前?

【问题讨论】:

    标签: sublimetext3 sublimelinter rubocop


    【解决方案1】:

    我发现这是 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-09
      • 1970-01-01
      • 1970-01-01
      • 2012-04-02
      • 2017-08-14
      • 1970-01-01
      相关资源
      最近更新 更多