简体   繁体   English

`bundle exec rake test:all` 失败并显示错误消息:`bundler: failed to load command: rake`

[英]`bundle exec rake test:all` fails with error message:`bundler: failed to load command: rake`

I pulled the changes from the git repo with git pull .我使用git pullgit库中提取了更改。 I then tried to run the tests in a Rails project:然后我尝试在 Rails 项目中运行测试:

$ DATABASE_ENV=test RAILS_ENV=test bundle exec rake test:all &> test.log

The tests fail with this error message:测试失败并显示以下错误消息:

$ cat test.log
bundler: failed to load command: rake (/Users/user_name/.rbenv/versions/2.7.3/bin/rake)
/Users/user_name/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bundler-2.2.26/lib/bundler/definition.rb:490:in `materialize': Could not find addressable-2.8.0, addressable-2.8.0, addressable-2.8.0, nokogiri-1.12.5-x86_64-darwin, nokogiri-1.12.5-x86_64-darwin, racc-1.6.0, racc-1.6.0, racc-1.6.0 in any of the sources (Bundler::GemNotFound)
        from /Users/user_name/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bundler-2.2.26/lib/bundler/definition.rb:228:in `specs_for'
...
        from /Users/user_name/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bundler-2.2.26/exe/bundle:37:in `<top (required)>'
        from /Users/user_name/.rbenv/versions/2.7.3/bin/bundle:23:in `load'
        from /Users/user_name/.rbenv/versions/2.7.3/bin/bundle:23:in `<main>'

How can I fix this error and enable the tests to actually run?如何修复此错误并使测试能够实际运行?

The file Gemfile.lock has probably changed in the repo, which causes some libraries to become missing.存储库中的文件Gemfile.lock可能已更改,这导致某些库丢失。 Make sure that this new version of the file looks OK.确保这个新版本的文件看起来没问题。 This can be done, for example, by comparing your old and new versions with git diff .例如,可以通过将旧版本和新版本与git diff进行比较来完成此操作。 If these are the changes you indeed want, install the missing libraries using bundle install :如果这些是您确实想要的更改,请使用bundle install缺少的库:

$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake 13.0.3
... [many lines]
Installing racc 1.6.0 with native extensions
Installing addressable 2.8.0
Fetching nokogiri 1.12.5 (x86_64-darwin)
Installing nokogiri 1.12.5 (x86_64-darwin)
... [many lines]
Using sass-rails 5.1.0
Bundle complete! 48 Gemfile dependencies, 122 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

SEE ALSO:也可以看看:

Understanding the Gemfile.lock file了解 Gemfile.lock 文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM