测试环境无法加载gem

2024-04-09

  • 我的应用程序可以运行。
  • 我以前能够运行测试,但现在由于某种原因不能运行。
  • 从现在到那时发生的事情是我供应商activesupport(但我已经撤消了这些更改,事实上我处于一个完全独立/不相关的分支中)。
  • 我在工作期间运行的两个命令activesupport我不熟悉的是bundle --deployment and bundle --no-deployment。再说一遍,我believe我撤消了与这些更改相关的所有内容(至少到目前为止git status被关注到- 我总是跑步git status,并且了解所有代码库更改)。

我知道其他人也有类似的问题,但不是这个确切的问题:https://stackoverflow.com/search?q=require+cannot+load+such+file+LoadError https://stackoverflow.com/search?q=require+cannot+load+such+file+LoadError

我正在玩弄供应商activesupport按照此:如何提供 active_support 的修改版本以便在我的 Rails 应用程序中使用? https://stackoverflow.com/questions/25603171/how-to-vendor-a-modified-version-of-active-support-such-that-it-is-used-in-my-ra

当我尝试推动供应商时,我遇到了麻烦activesupport分支到staging: “在其他地方运行`bundle install`”中的“其他地方”在哪里? https://stackoverflow.com/questions/25612444/where-is-elsewhere-in-run-bundle-install-elsewhere

无论如何,重点是我的应用程序可以运行(即所有宝石显然都已安装,Gemfile and 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 `<top (required)>'
  from test/controllers/photos_controller_test.rb:1:in `require'
  from test/controllers/photos_controller_test.rb:1:in `<main>'

如果我注释掉该行10 of test/test_helper.rb,它只是抱怨下一个require line.

dependencies.rb:229:in `require': cannot load such file -- minitest/rails/capybara (LoadError)
...
test/test_helper.rb:14:in `<top (required)>'

当我注释掉这一行时14,它抱怨下一个require线等等...

所以看来在test环境,看不到宝石。想法?

.bundle/配置

---
BUNDLE_WITHOUT: development:test

配置BUNDLE_WITHOUT: development:test告诉 Bundler 不要从development and test组。由于这是您唯一的配置设置,因此您可以安全地删除.bundle/config文件和事情应该会恢复为您工作。

或者,您可以保留该文件并仅删除该行。

有没有可能当你跑的时候bundle --deployment,你实际上跑了bundle --deployment --without development test?这些选项通常一起使用,选项传递给bundle install (or bundle没有子命令,默认为install)被记住在bundle/.config文件。这些选项在被明确删除之前是“粘性的”,所以如果您使用--without标记一次,您需要编辑文件才能恢复这些组。

另请注意.bundle/config通常被排除在 git 之外,所以检查git status不会告诉你它是否改变。这些设置通常依赖于机器,因此最好将其从 git 中排除。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

测试环境无法加载gem 的相关文章

随机推荐