【问题标题】:$GEM is not part of the bundle. Add it to Gemfile$GEM 不是捆绑包的一部分。将其添加到 Gemfile
【发布时间】:2016-06-24 09:53:22
【问题描述】:

突然我不能再运行 rspec 或 guard 了。我什至对一个旧提交进行了检查,我知道我有一些测试正在运行。同样的错误。

$ git checkout known-working-commit && bundle && rspec spec
.../ruby-2.2.3@solidus/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:304:in 
`block in replace_gem': rspec-core is not part of the bundle. 
Add it to Gemfile. (Gem::LoadError)

如果我运行 rspecguard,我会得到同样的错误。 查看rvm info 公开的PATH,我发现可以在/Users/martins/.rvm/gems/ruby-2.2.3@solidus/bin/guard 找到该保护。 $PATH 也有 /Users/martins/.rvm/gems/ruby-2.2.3@solidus/bin 作为它的第一个条目。 知道可能出了什么问题吗?我认为通过在 PATH 中首先列出一个目录会使其优先于列出的其他目录。我怎么会收到"bundler-1.11.2/lib/bundler/rubygems_integration.rb:304:in block in replace_gem': rspec-core is not part of the bundle. Add it to Gemfile" 错误?

我正在运行 OS X 10.10.5 和 ZSH。

我的测试部分来自 Gemfile

 19 group :test do
 20   gem 'factory_girl_rails', '~> 4.5.0'
 21   gem 'capybara', '~> 2.4'
 22   gem 'capybara-screenshot'
 23   gem 'database_cleaner', '~> 1.3'
 24   gem 'email_spec'
 25   gem 'launchy'
 26   gem 'rspec-activemodel-mocks', '~>1.0.2'
 27   gem 'rspec-collection_matchers'
 28   gem 'rspec-its'
 29   gem 'rspec-rails', '~> 3.3.0'
 30   gem 'simplecov'
 31   gem 'webmock', '1.8.11'
 32   gem 'poltergeist'
 33   gem 'timecop'
 34   gem 'with_model'
 35   gem 'rspec_junit_formatter'
 36 end

相同的分支在我的工作计算机上按预期工作。这让我觉得有些环境设置搞砸了。

【问题讨论】:

  • 你做到了吗? rspec 在你的 Gemfile 中吗?
  • 是的,我在 Gemfile 中获得了 rspec,并且已经运行了 bundle。如果我在另一台计算机上检查代码,它就可以工作。我认为这是特定于环境的事情。

标签: ruby-on-rails ruby rspec rubygems osx-yosemite


【解决方案1】:

仅在PATHGEM_PATH 中使用gem 是不够的。您的应用程序需要require 它。将它添加到 Gemfile 并捆绑它可确保 bundler 需要它。

确保rspecrspec-rails(如果基于rails 的应用程序)包含在您的Gemfile 中。

【讨论】:

  • 您可以在我的主帖中看到我的 Gemfile。
猜你喜欢
  • 2023-03-29
  • 2023-03-12
  • 1970-01-01
  • 2020-07-08
  • 2015-11-19
  • 1970-01-01
  • 2017-04-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多