无法在测试环境中加载宝石 [英] cannot load gems in test environment
问题描述
activesupport
(但是我已经取消了这些更改,实际上我处于完全独立/不相关的分支) 。 我在工作期间运行的两个命令 activesupport
我不熟悉 bundle - 无部署
。再次,我相信我解开了与这些更改有关的所有事情(至少就 git status
而言) - 我总是运行 git status
,并且知道所有的代码库变化)。我知道其他人有类似的,但不是这个确切的问题: https:// stackoverflow.com/search?q=require+cannot+load+such+file+LoadError
我在玩弄 activesupport
以下内容:
如何提供active_support的修改版本,以便在我的Rails应用程序中使用它?
我尝试将供应商 activesupport
分支推送到分段存储
:
<一个href =https://stackoverflow.com/ques tions / 25612444 / where-is-others-in-run-bundle-install-elsewhere>在其他地方的运行捆绑软件安装其他位置中的别处在哪里?$ /
无论如何,重点在于我的应用程序有效(即所有的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':无法加载这样的文件 - 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:在`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:在`load_dependency'
from /Users/bsimpson/.rvm/gems/ruby-2.0.0 -p481@books/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:在'require'中
从/ Volumes / MyHD / Users / bsimpson / Dev / books / books / test / test_helper .rb:10:在< top(required)>'
from test / controllers / photos_controller_test.rb:1:'require'
from test / controllers / photo s_controller_test.rb:1:在< main>'
如果我注释掉 10
require
dependencies.rb:229:in'require':无法加载这样的文件 - minitest / rails / capybara LoadError)
...
test / test_helper.rb:14:<< top(required)>'
当我注释掉 14
时,它会抱怨下一个 require
行,等等...
因此,在测试
环境中,gem aren'没见过。想法?
.bundle / config
---
BUNDLE_WITHOUT:development:test
配置 BUNDLE_WITHOUT:development:test
告诉Bundler不要从开发
和<$ c $加载宝石c> test 组。由于这是您唯一的配置设置,因此您可以安全地删除 .bundle / config
文件,并且应该返回给您工作。
或者,您可以保留该文件并仅删除该行。
有可能当您运行 bundle - 部署
,你实际上运行了 bundle --deployment - 没有开发测试
?这些选项通常一起使用,并且传递给 bundle install
(或 bundle
)的选项不带子命令,其中缺省值至 install
)会记住在 bundle / .config
文件中。这些选项在被明确删除之前是粘性的,所以如果你使用 - 没有
标志一次,你需要编辑文件来恢复这些组。
另请注意,通常从git中排除 .bundle / config
,因此请检查 git状态
不会告诉你它是否改变。这些设置通常是依赖于机器的,所以最好将它从git中排除。
- My app works.
- I was able to run tests before, and now for some reason I can't.
- What happened between now and then is that I vendorized
activesupport
(but I have since undone those changes, and in fact I am in a totally separate/unrelated branch). - Two commands I ran during my work on
activesupport
that I am unfamiliar with arebundle --deployment
andbundle --no-deployment
. Again, I believe I undid everything related to those changes (at least as far asgit status
is concerned - I always rungit status
, and am aware of all codebase changes).
I am aware that other people have had similar, but not this exact problem: https://stackoverflow.com/search?q=require+cannot+load+such+file+LoadError
I was playing around with vendorizing activesupport
following this:
How to vendor a modified version of active_support such that it is used in my Rails app?
And I had trouble when I tried pushing the vendorized activesupport
branch to staging
:
Where is 'elsewhere' in "run `bundle install` elsewhere"?
Anyway, the point is that my app works (i.e. all the gems are obviously installed, Gemfile
and Gemfile.lock
are intact), yet I cannot run tests:
/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>'
If I comment out line 10
of test/test_helper.rb
, it just complains about the next require
line.
dependencies.rb:229:in `require': cannot load such file -- minitest/rails/capybara (LoadError)
...
test/test_helper.rb:14:in `<top (required)>'
And when I comment out line 14
, it complains about the next require
line, and so on...
So it seems that in the test
environment, the gems aren't seen. Thoughts?
.bundle/config
---
BUNDLE_WITHOUT: development:test
The configuration BUNDLE_WITHOUT: development:test
tells Bundler not to load gems from the development
and test
groups. Since this is your only configuration setting, you can safely delete the .bundle/config
file and things should go back to working for you.
Alternatively, you could leave the file and only delete that line.
Is it possible that when you ran bundle --deployment
, you actually ran bundle --deployment --without development test
? These options are commonly used together, and options passed to bundle install
(or bundle
without a sub-command, which defaults to install
) are remembered in the bundle/.config
file. These options are "sticky" until they are explicitly removed, so if you use the --without
flag once, you'll need to edit the file to get those groups back.
Also note that .bundle/config
is usually excluded from git, so checking git status
won't tell you if it changed. These settings are often machine-dependent, so it's a good idea to keep it excluded from git.
这篇关于无法在测试环境中加载宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!