3

我試圖在生產模式與本地運行:軌道 - 正在運行的生產模式在本地=沒有這樣的文件來加載 - 配置/環境

$ RAILS_ENV=production rails s 

,但我得到:

/home/durrantm/.rvm/gems/[email protected]/gems/activesupport-3.1.8/li 
b/active_support/dependencies.rb:306:in `rescue in depend_on': No such file 
to load -- /home/durrantm/Dropnot/webs/rails_apps/linker/app/assets/../con 
fig/environment (LoadError) 

我可以創建一個全新的導軌3.1.8應用程序和做RAILS_ENV=production rails server,我不明白這個問題。

我還可以做rails s並運行在開發模式服務器罰款沒有錯誤。

我還可以做RAILS_ENV=development rails s並運行在開發模式服務器罰款沒有錯誤。

FWIW,我的應用程序本來是一個軌道2.3應用程序,所以也許我缺少一個已經添加或更改軌道的東西嗎?

我確實有config目錄與environment.rb文件。或許它被引用的方式在某種程度上是錯誤的?

我加config.assets.enabled = trueconfig/application.rb但它沒有幫助(沒想到它是因爲這是資產編譯,但它是我發現的差異!)。

完全跟蹤:

[email protected]:~/Dropnot/webs/rails_apps/linker/config/environments (v3.1.8_with_assets) 
$ RAILS_ENV=production rails s 
=> Booting WEBrick 
=> Rails 3.1.8 application starting in production on http://0.0.0.0:3000 
=> Call with -d to detach 
=> Ctrl-C to shutdown server 
Exiting 
/home/durrantm/.rvm/gems/[email protected]/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:306:in `rescue in depend_on': No such file to load -- /home/durrantm/Dropnot/webs/rails_apps/linker/app/assets/../config/environment (LoadError) 
     from /home/durrantm/.rvm/gems/[email protected]/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:301:in `depend_on' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:214:in `require_dependency' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/engine.rb:417:in `block (2 levels) in eager_load!' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/engine.rb:416:in `each' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/engine.rb:416:in `block in eager_load!' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/engine.rb:414:in `each' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/engine.rb:414:in `eager_load!' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/application/finisher.rb:51:in `block in <module:Finisher>' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/initializable.rb:30:in `instance_exec' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/initializable.rb:30:in `run' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/initializable.rb:55:in `block in run_initializers' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/initializable.rb:54:in `each' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/initializable.rb:54:in `run_initializers' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/application.rb:96:in `initialize!' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/railtie/configurable.rb:30:in `method_missing' 
     from /home/durrantm/Dropnot/webs/rails_apps/linker/config/environment.rb:5:in `<top (required)>' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `require' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `block in require' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:223:in `block in load_dependency' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:640:in `new_constants_in' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:223:in `load_dependency' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `require' 
     from /home/durrantm/Dropnot/webs/rails_apps/linker/config.ru:4:in `block in <main>' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize' 
     from /home/durrantm/Dropnot/webs/rails_apps/linker/config.ru:1:in `new' 
     from /home/durrantm/Dropnot/webs/rails_apps/linker/config.ru:1:in `<main>' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/builder.rb:40:in `eval' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/builder.rb:40:in `parse_file' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/server.rb:200:in `app' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/commands/server.rb:46:in `app' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/server.rb:301:in `wrapped_app' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/server.rb:252:in `start' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/commands/server.rb:70:in `start' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/commands.rb:54:in `block in <top (required)>' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/commands.rb:49:in `tap' 
     from /home/durrantm/.rvm/gems/[email protected]/gems/railties-3.1.8/lib/rails/commands.rb:49:in `<top (required)>' 
     from script/rails:6:in `require' 
     from script/rails:6:in `<main>' 
+1

東西很奇怪。它正在尋找'app /'目錄內的'config /'目錄。它不應該在那裏看。 –

+0

是的,這是肯定的奇怪的部分... –

+0

可能會導致什麼?這是我幾年來運行良好並通過幾個rails版本升級的應用程序,並沒有遇到類似的情況。我目前正在通過'config /'目錄進行操作(現在我正在通過'initializers /',但還沒有看到任何東西... –

回答

1

好像舊assets目錄住在其他地方(也許在public),現在它是在app/assets,但它不知道它和一些文件嘗試加載environment.rb。只需再次檢查資產目錄。

+0

是的,資產以前只是在'public /'。我已經將它們移動到/ app/assets /我試着做一個'rake資產:預編譯',但它沒有我不希望創建'/ public'結構.. –

+0

啊,添加公共目錄很重要,一旦我添加了那個目錄,'rake assets:precompile'就能夠將資產複製到'public/assets'目錄。不幸的是,這*仍然*給出'沒有這樣的文件加載 -/home/durrantm/Dropnot/webs/rails_apps/linker/app/assets /../ config/environment(LoadError)'msg當我執行'RAILS_ENV = production rails s'時。 GRRRR! –

+0

btw「雙重檢查資產目錄」,當然,...? –

3

改變了一些東西。其中一個主要原因是在試圖在本地運行(僅)在本地啓用靜態資產config/environments/production.rb,並在推送到生產Web服務器之前恢復該靜態資產。我不知道。

相關問題