Several RoR web apps have been running on a server for years and been regularly updated with the latest versions of ruby, rails and mod_passenger. Now, suddenly one particular app (none of the other apps, even though they are using an identical setup) has developed the problem described below.
I'm on Alma Linux 8.10 currently with Apache 2.4.37, mod_passenger 6.0.23, ruby 3.3.3 via rbenv and rails 7.2.1. Deployment is via capistrano 3.19.1 and capistrano-passenger 0.2.1.
Here's the (abbreviated) error message in /var/log/httpd/error_log
which happens when I first try to access the app in a browser after deployment:
/home/user/.rbenv/versions/3.3.3/bin/ruby: No such file or directory -- Passenger AppPreloader: /var/www/me.mio/current (LoadError)
[...age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/me.mio/current: The application process exited prematurely.
age/Cor/Con/CheckoutSession.cpp:284 ]: Cannot checkout session because a spawning error occurred.
At the moment (thanks to comments by engineersmnky) the interpretation of this error message is that ruby thinks the capistrano current directory does not exist.
Here's some relevant lines from the /etc/httpd/conf.d
file:
<VirtualHost *:443>
...
PassengerRuby /home/user/.rbenv/shims/ruby
PassengerMinInstances 1
...
</VirtualHost>
PassengerPreStart https://...
Here's the result of running some commands in the app's current
directory, which does exist:
$ cat .ruby-version # 3.3.3
$ rbenv version # 3.3.3 (set by /var/www/me.mio/current/.ruby-version)
$ ruby -v # ruby 3.3.3 ...
$ which ruby # ~/.rbenv/shims/ruby
$ rbenv rehash # doesn't help
$ ls -l ~/.rbenv/versions/3.3.3/bin/ruby
-rwxr-xr-x 1 ... 217824 Jun 13 19:00 /home/user/.rbenv/versions/3.3.3/bin/ruby
$ ~/.rbenv/versions/3.3.3/bin/ruby -v # ruby 3.3.3 ...
Finally, here is the output from passenger-status
. Note that the difference between the me.mio
app (the one with the problem) and the others.
Version : 6.0.23
Date : 2024-09-03 10:39:24 +0000
Instance: LEqbzjUQ (Apache/2.4.37 (AlmaLinux) OpenSSL/1.1.1k Phusion_Passenger/6.0.23)
----------- General information -----------
Max pool size : 6
App groups : 5
Processes : 4
Requests in top-level queue : 0
----------- Application groups -----------
/var/www/me.mio/current (production):
App root: /var/www/me.mio/current
Requests in queue: 0
/var/www/smd/current (production):
App root: /var/www/smd/current
Requests in queue: 0
* PID: 128934 Sessions: 0 Processed: 7 Uptime: 1h 15m 50s
CPU: 0% Memory : 78M Last used: 3m 35s
/var/www/wd/current (production):
App root: /var/www/wd/current
Requests in queue: 0
* PID: 129234 Sessions: 0 Processed: 11 Uptime: 1h 15m 45s
CPU: 0% Memory : 77M Last used: 13m 40s
/var/www/me.hou/current (production):
App root: /var/www/me.hou/current
Requests in queue: 0
* PID: 139227 Sessions: 0 Processed: 1 Uptime: 16m 15s
CPU: 0% Memory : 68M Last used: 16m 15s ag
/var/www/me.sta/current (production):
App root: /var/www/me.sta/current
Requests in queue: 0
* PID: 132177 Sessions: 0 Processed: 1 Uptime: 56m 53s
CPU: 0% Memory : 52M Last used: 56m 53s ag
There is no useful information in the /tmp/.../passenger-error-*.html
file generated by passenger.
Does anyone have any ideas or suggest how to investigate further?
The versions of Rubygems (3.5.17) and Bundler (2.5.11) had got out of sync. This did not affect development tests but caused a problem when deployed.
Deleting the version of bundler in Gemfile.lock
, running bundle update
(so bundler is now 2.5.17), committing and redeploying fixed it.
One way to help notice the out of sync versions is to run bin/cap production doctor
(or bundle exec cap production doctor
).