0

For reasons beyond my control, I need to run a Rails 4 app on CentOS 7. Currently, it is running successfully on a Red Hat with rvm and Passenger. I'd like to migrate it over to rbenv and Puma but I am stuck with this issue.

I am trying to run a test installation on a VirtualBox virtual machine. I believe I've wired everything together correctly. I have disabled SELinux. When I run cap deploy, puma starts successfully:

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 deploy@localhost 0.537s

But the Puma access log spins out this error in an infinite loop:

/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 ...

Listing the processes associated with my Puma user shows:

$ 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

I have confirmed that I can successfully run Bundler as the deploy user that owns the Rails application and the Puma process:

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

So I am not sure why am I seeing this error. After hours of research and troubleshooting, I'm stuck. I can provide config files if needed but they're pretty standard and I think would only clutter up this question at this point.

Does this issue look familiar to anyone?

Chapman Atwell
  • 1,007
  • 1
  • 9
  • 13

1 Answers1

1

Few steps to solve this type of issue:

  1. Make sure that bundler is properly installed. Looks like yes in your case, but still a good thing to start by running a gem install bundler
  2. Make sure that all your path is properly configured. Here is an example that looks similar to your case, where bundler was installed but path wasn't correct and bundler versions were mixed: cannot load such file -- bundler/setup (LoadError)
  3. If you are using RVM you might want to take a look at: LoadError: cannot load such file -- bundler/setup
Stephane Paquet
  • 2,315
  • 27
  • 31
  • Thanks for the suggestions, Stephane. It hasn't solved my problem but has provided a couple new threads to pull on. It also led me to [this question](https://stackoverflow.com/q/30502765/6763239) which looks like it could be relevant. I added `ps aux` output to my question. – Chapman Atwell Aug 28 '17 at 15:43
  • Actually, [this comment here](https://stackoverflow.com/questions/30502765/puma-looks-ok-but-cycles-through-life-defunct-life-defunct-every-10-seconds#comment51274220_30502765) turned out to be the solution to my issue. Once I changed the owner of `/var` and `/var/www` to my `deploy` user, Puma was able to run successfully. @stephane-paquet, if you wish to add that to the top of your answer, I'll select your answer as the correct one then add my own answer with the details. Thanks again for your help. – Chapman Atwell Aug 28 '17 at 16:22