2017-08-25 80 views
0

由於我無法控制的原因,我需要在CentOS 7上運行Rails 4應用程序。目前,它已在rvm和Passenger的Red Hat上成功運行。我想將它遷移到rbenv和Puma,但我陷入了這個問題。爲什麼Puma無法在擁有Puma進程的用戶可以加載Bundler?

我想在VirtualBox虛擬機上運行測試安裝。我相信我已經正確地把所有東西連接起來我禁用了SELinux。當我運行cap deploy,彪馬成功啓動:

04:03 puma:start 
     using conf file /var/www/rails-app/shared/puma.rb 
     01 bundle exec puma -C /var/www/rails-app/shared/puma.rb --daemon 
     01 * Pruning Bundler environment 
     01 [6464] Puma starting in cluster mode... 
     01 [6464] * Version 3.9.1 (ruby 2.1.10-p492), codename: Private Caller 
     01 [6464] * Min threads: 4, max threads: 16 
     01 [6464] * Environment: vm 
     01 [6464] * Process workers: 1 
     01 [6464] * Phased restart available 
     01 [6464] * Listening on unix:///var/www/rails-app/shared/tmp/sockets/puma.sock 
     01 [6464] * Daemonizing... 
    ✔ 01 [email protected] 0.537s 

但彪馬訪問日誌旋轉出這個錯誤在一個無限循環:

/home/deploy/.rbenv/versions/2.1.10/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError) 
... stack trace clipped ... 

清單與我彪馬用戶關聯的進程顯示:

$ ps aux | grep deploy 
deploy 12645 0.0 0.2 115384 2084 pts/0 S 18:18 0:00 -bash 
deploy 18517 0.7 1.7 271344 18076 ?  Sl 18:27 0:00 puma 3.9.1 (unix:///var/www/rails-app/shared/tmp/sockets/puma.sock) 
deploy 23279 7.0 0.0  0  0 ?  Z 18:29 0:00 [ruby] <defunct> 
deploy 23283 4.0 1.7 273400 17464 ?  Rl 18:29 0:00 puma: cluster worker 0: 18517 

我確認我可以成功運行Bundler作爲擁有Rails應用程序和Puma進程的deploy用戶:

cd /var/www/rails-app/current && bundler --version 
Bundler version 1.15.4 

所以我不知道爲什麼我會看到這個錯誤。經過數小時的研究和故障排除,我陷入困境。如果需要,我可以提供配置文件,但它們非常標準,我認爲在這一點上只會混淆這個問題。

這個問題看起來對任何人都很熟悉嗎?

+0

你的問題似乎是類似於這一個https://stackoverflow.com/questions/19061774/cannot-load-such-file-bundler-setup-loaderror –

+0

如果您使用RVM https://stackoverflow.com/questions/32670779/loaderror-can-load-such-file-bundler-setup –

回答

0

很少的措施來解決這一類問題:

  1. 確保捆綁安裝正確。看起來像在你的情況是,但仍然是一個好東西開始運行gem install bundler
  2. 確保所有的路徑都正確配置。下面是一個類似於你的情況下,如果捆綁安裝,但道路是不正確的和捆綁的版本進行混合的例子:cannot load such file -- bundler/setup (LoadError)
  3. 如果您正在使用RVM你可能想看一看:LoadError: cannot load such file -- bundler/setup
+0

感謝您的建議,Stephane。它沒有解決我的問題,但提供了一些新的線索來拉。這也導致我[這個問題](https://stackoverflow.com/q/30502765/6763239)看起來可能是相關的。我爲我的問題添加了'ps aux'輸出。 –

+0

其實,[此處留言](https://stackoverflow.com/questions/30502765/puma-looks-ok-but-cycles-through-life-defunct-life-defunct-every-10-seconds#comment51274220_30502765)轉身成爲我的問題的解決方案。一旦我將'/ var'和'/ var/www'的所有者更改爲我的'deploy'用戶,Puma就能夠成功運行。 @ stephane-paquet,如果您想將其添加到答案的頂部,我會選擇您的答案作爲正確答案,然後添加我自己的答案和詳細信息。再次感謝你的幫助。 –