【问题标题】:Chef: cannot load such file -- rubocop/formatter/checkstyle_formatter厨师:无法加载这样的文件——rubocop/formatter/checkstyle_formatter
【发布时间】:2015-04-14 18:44:28
【问题描述】:

我正在运行以下命令:

rubocop --require rubocop/formatter/checkstyle_formatter --format RuboCop::Formatter::CheckstyleFormatter --no-color --silent --rails --out checkstyle.xml

并得到这个错误:

C:/opscode/chefdk/embedded/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- rubocop/formatter/checkstyle_formatter (LoadError)

环境是 Windows 上的 Chef-DK 0.4.0。我已经安装了 gem:

gem install rubocop-checkstyle_formatter

RuboCop (0.28.0) 在 Chef-DK 0.4.0 中交付,并且在没有 Formater 的情况下它可以工作。

这是Formater的页面:https://github.com/eitoball/rubocop-checkstyle_formatter

我没有通过谷歌搜索或在 stackoverflow 中找到任何解决方案。 任何提示如何解决或分析问题?我是 Ruby 新手。

【问题讨论】:

  • 真的很奇怪。我尝试了几件事: - 设置、更改和删除 GEM_PATH、GEM_HOME 等。没有任何帮助。 Ruby 没有找到格式化程序。然后我卸载了 Chef-DK 并清理了所有环境变量。全新安装后,它工作正常。它会找到以前安装的 gem。

标签: ruby chef-infra rubocop


【解决方案1】:

我以一种比较老套的方式解决了这个问题,但它确实有效。所以基本上 cd 进入你的 rubocop gem 文件夹(比如 /home/ec2-user/.rvm/gems/ruby-2.1.2/gems/rubocop-0.34.2/lib/rubocop),然后你会看到一个名为 formatter 的目录,然后 cd 进入该格式化程序文件夹,您将看到一堆用于不同格式化程序的 .rb 文件。 现在解决方案来了。

touch checkstyle_formatter.rb

然后将https://github.com/eitoball/rubocop-checkstyle_formatter/blob/master/lib/rubocop/formatter/checkstyle_formatter.rb 复制到您刚刚创建的文件中。

那你应该可以走了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-19
    • 2019-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多