无法在测试环境中加载gem
- 我的应用有效。
- 之前我能够进行测试,现在由于某种原因,我不能。
- 从现在到现在发生的事情是我提供了
activesupport
(但我已经撤消了这些更改,事实上我在一个完全独立/无关的分支)。 - 我在
activesupport
工作期间运行的两个我不熟悉的命令是bundle --deployment
和bundle --no-deployment
。 同样,我相信我解除了与这些更改相关的所有事情( 至少就git status
而言 – 我总是运行git status
,并且知道所有代码库更改)。
我知道其他人有类似的问题,但不是这个问题: https : //stackoverflow.com/search?q = require + can not+load+such+ file+LoadError
我正在玩这样的供应商 activesupport
: 如何供应修改后的active_support版本,以便在我的Rails应用程序中使用它?
当我尝试将供应商的activesupport
分支推送到staging
时,我遇到了麻烦: “run` bundle install`在其他地方的’其他地方’哪里”?
无论如何,重点是我的应用程序工作 (即显然安装了所有gem, Gemfile
和Gemfile.lock
完好无损), 但我无法运行测试 :
/Users/bsimpson/.rvm/gems/ruby-2.0.0-p481@books/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require': cannot load such file -- minitest/rails (LoadError) from /Users/bsimpson/.rvm/gems/ruby-2.0.0-p481@books/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `block in require' from /Users/bsimpson/.rvm/gems/ruby-2.0.0-p481@books/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:214:in `load_dependency' from /Users/bsimpson/.rvm/gems/ruby-2.0.0-p481@books/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require' from /Volumes/MyHD/Users/bsimpson/Dev/books/books/test/test_helper.rb:10:in `' from test/controllers/photos_controller_test.rb:1:in `require' from test/controllers/photos_controller_test.rb:1:in `'
如果我注释掉test/test_helper.rb
第10
行,它就会抱怨下一个require
行。
dependencies.rb:229:in `require': cannot load such file -- minitest/rails/capybara (LoadError) ... test/test_helper.rb:14:in `'
当我在第14
行发表评论时,它抱怨下一个require
行,依此类推……
因此,在test
环境中,似乎没有看到gem。 思考?
.bundle /配置
--- BUNDLE_WITHOUT: development:test
配置BUNDLE_WITHOUT: development:test
告诉Bundler不要从development
和test
组加载gem。 由于这是您唯一的配置设置,因此您可以安全地删除.bundle/config
文件,并且应该重新为您工作。
或者,您可以保留文件并仅删除该行。
有可能当你运行bundle --deployment
,你实际上运行了bundle --deployment --without development test
吗? 这些选项通常一起使用,并且bundle/.config
文件中会记住传递给bundle install
选项(或没有子命令的bundle
,默认install
)。 这些选项在显式删除之前是“粘性的”,因此如果您使用--without
标志一次,则需要编辑该文件以恢复这些组。
另请注意, .bundle/config
通常从git中排除,因此检查git status
不会告诉您它是否更改。 这些设置通常取决于机器,因此最好将它从git中排除。