6

Viene visualizzato il seguente errore quando eseguo la mia applicazione Rails in modalità di produzione, ma quando eseguo la mia app in modalità di sviluppo funziona correttamente. Posso usare gemme in modalità produzione?`require ': Nessun file da caricare - test_helper (LoadError)

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

che segue è la piena traccia del codice:

/home/nyros/.rvm/gems/[email protected]/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/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require' 
from /home/nyros/.rvm/gems/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency' 
from /home/nyros/.rvm/gems/[email protected]/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/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require' 
from /home/nyros/.rvm/gems/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require' 
from /home/nyros/.rvm/gems/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency' 
from /home/nyros/.rvm/gems/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require' 
from /home/nyros/.rvm/gems/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:330:in `require_or_load' 
from /home/nyros/.rvm/gems/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:289:in `depend_on' 
from /home/nyros/.rvm/gems/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:207:in `require_dependency' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/engine.rb:464:in `each' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/engine.rb:464:in `block in eager_load!' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/engine.rb:462:in `each' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/engine.rb:462:in `eager_load!' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/engine.rb:347:in `eager_load!' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/application/finisher.rb:56:in `each' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run' 
from /home/nyros/.rvm/gems/[email protected]/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/[email protected]/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!' 
from /home/nyros/.rvm/gems/[email protected]/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/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require' 
from /home/nyros/.rvm/gems/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require' 
from /home/nyros/.rvm/gems/[email protected]/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency' 
from /home/nyros/.rvm/gems/[email protected]/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/[email protected]/gems/rack-1.5.5/lib/rack/builder.rb:55:in `instance_eval' 
from /home/nyros/.rvm/gems/[email protected]/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/[email protected]/gems/rack-1.5.5/lib/rack/builder.rb:49:in `eval' 
from /home/nyros/.rvm/gems/[email protected]/gems/rack-1.5.5/lib/rack/builder.rb:49:in `new_from_string' 
from /home/nyros/.rvm/gems/[email protected]/gems/rack-1.5.5/lib/rack/builder.rb:40:in `parse_file' 
from /home/nyros/.rvm/gems/[email protected]/gems/rack-1.5.5/lib/rack/server.rb:277:in `build_app_and_options_from_config' 
from /home/nyros/.rvm/gems/[email protected]/gems/rack-1.5.5/lib/rack/server.rb:199:in `app' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app' 
from /home/nyros/.rvm/gems/[email protected]/gems/rack-1.5.5/lib/rack/server.rb:314:in `wrapped_app' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in `start' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>' 
from /home/nyros/.rvm/gems/[email protected]/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap' 
from /home/nyros/.rvm/gems/[email protected]/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>' 
+0

Condividi alcune più linee di traccia dello stack –

+0

Perché si cerca di caricare un 'test_helper' nel' ambiente di produzione? In quale file ottieni questo errore? – spickermann

+0

Stai provando a eseguire test nell'ambiente 'production'? E post backtrace per favore – Vasfed

risposta

11

Hai un test, quarterly_export_statement_test.rb, nella directory app/controllers.

In produzione, Rails carica tutte le classi con impazienza, quindi tenta di caricare il test. Il tuo test fa require 'test_helper'. La directory test, che contiene test_helper, non si trova nel percorso di caricamento nell'ambiente di produzione (buono!), Quindi non è necessario.

Per risolvere il problema, spostare il test nella directory test a cui appartiene, che sembra essere /home/nyros/Documents/Projects/DFL/Working/DFL/test.

+0

Ero un po 'scocciato dalla parte del percorso del motore, ma nel caso dell'OP la risposta, @dave, è corretta. In generale i motori non devono essere sotto ./app, dal momento che, come hai detto, * tutti i file * sotto l'app verranno caricati con entusiasmo in produzione. – radiospiel

0

ho ottenuto lo stesso errore durante l'uso: railstutorial.org Capitolo 6. Il file incriminato per me era app/helpers/application_helper_test.rb che aveva require 'test_helper' in alto.

ho commentato che la linea fuori, ha fatto

git add -A 
git push 
git push heroku 

poi corse heroku run console, che ha lavorato :)