为什么Puma无法在拥有Puma进程的用户可以加载Bundler?

问题描述:

由于我无法控制的原因,我需要在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://*.com/questions/19061774/cannot-load-such-file-bundler-setup-loaderror –

+0

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

很少的措施来解决这一类问题:

  1. 确保捆绑安装正确。看起来像在你的情况是,但仍然是一个好东西开始运行gem install bundler
  2. 确保所有的路径都正确配置。下面是一个类似于你的情况下,如果捆绑安装,但道路是不正确的和捆绑的版本进行混合的例子:cannot load such file -- bundler/setup (LoadError)
  3. 如果您正在使用RVM你可能想看一看:LoadError: cannot load such file -- bundler/setup
+0

感谢您的建议,Stephane。它没有解决我的问题,但提供了一些新的线索来拉。这也导致我[这个问题](https://*.com/q/30502765/6763239)看起来可能是相关的。我为我的问题添加了'ps aux'输出。 –

+0

其实,[此处留言](https://*.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,如果您想将其添加到答案的顶部,我会选择您的答案作为正确答案,然后添加我自己的答案和详细信息。再次感谢你的帮助。 –