`require': 没有要加载的文件 -- test_helper (LoadError) [英] `require': No such file to load -- test_helper (LoadError)

查看:46
本文介绍了`require': 没有要加载的文件 -- test_helper (LoadError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在生产模式下运行我的 Rails 应用程序时出现以下错误,但是当我在开发模式下运行我的应用程序时它工作正常.我可以在生产模式下使用任何宝石吗?

I get the following error when I run my Rails application in production mode, but when I run my app in development mode it works fine. Can I use any gems in production mode?

`require': No such file to load -- test_helper (LoadError)

以下是代码的完整跟踪:

The following is the full trace of the code:

 /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require': No such file to load -- test_helper (LoadError)
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from /home/nyros/Documents/Projects/DFL/Working/DFL/app/controllers/quarterly_export_statement_test.rb:1:in `<top (required)>'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:330:in `require_or_load'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:289:in `depend_on'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:207:in `require_dependency'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/engine.rb:464:in `each'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/engine.rb:464:in `block in eager_load!'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/engine.rb:462:in `each'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/engine.rb:462:in `eager_load!'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/engine.rb:347:in `eager_load!'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/application/finisher.rb:56:in `each'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'  
from /home/nyros/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `each'
from /home/nyros/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `call'
from /home/nyros/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
from /home/nyros/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
from /home/nyros/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/nyros/Documents/Projects/DFL/Working/DFL/config/environment.rb:5:in `<top (required)>'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from /home/nyros/Documents/Projects/DFL/Working/DFL/config.ru:3:in `block in <main>'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/rack-1.5.5/lib/rack/builder.rb:55:in `instance_eval'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/rack-1.5.5/lib/rack/builder.rb:55:in `initialize'
from /home/nyros/Documents/Projects/DFL/Working/DFL/config.ru:in `new'
from /home/nyros/Documents/Projects/DFL/Working/DFL/config.ru:in `<main>'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/rack-1.5.5/lib/rack/builder.rb:49:in `eval'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/rack-1.5.5/lib/rack/builder.rb:49:in `new_from_string'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/rack-1.5.5/lib/rack/builder.rb:40:in `parse_file'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/rack-1.5.5/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/rack-1.5.5/lib/rack/server.rb:199:in `app'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/rack-1.5.5/lib/rack/server.rb:314:in `wrapped_app'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in `start'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

推荐答案

您在 app/controllers 目录中有一个测试,quarterly_export_statement_test.rb.

You have a test, quarterly_export_statement_test.rb, in your app/controllers directory.

在生产环境中,Rails 会急切地加载所有类,因此它会尝试加载您的测试.您的测试需要'test_helper'.包含 test_helpertest 目录不在生产环境的加载路径中(很好!),因此 require 失败.

In production, Rails loads all classes eagerly, so it attempts to load your test. Your test does require 'test_helper'. The test directory, which contains test_helper, isn't in the load path in the production environment (good!), so that require fails.

要解决问题,将测试移动到它所属的test目录下,该目录看起来是/home/nyros/Documents/Projects/DFL/Working/DFL/test.

To fix the problem, move the test to the test directory where it belongs, which appears to be /home/nyros/Documents/Projects/DFL/Working/DFL/test.

这篇关于`require': 没有要加载的文件 -- test_helper (LoadError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆