skip to Main Content

I’m on a shared server with cPanel, EasyApache4 and Phusion Passenger.
My app was running fine with ruby 2.1.6 (in a shared directory) and rails 4.2.6.
I had a .htaccess file:

PassengerEnabled on 
PassengerLoadShellEnvVars On 
PassengerAppRoot /home/adminxxx/webapps/assist2prod/current/ 
PassengerRuby /usr/local/ruby20/bin/ruby

## General Apache options 
#AddHandler cgi-script .cgi 
#Options +FollowSymLinks +ExecCGI

# Redirect all requests not available on the filesystem to Rails 
RewriteEngine On 
RailsEnv production 
RackEnv production

#ErrorDocument 500 "<h2>Production Application error</h2>Rails application failed to start properly"

The server decided to upgrade and now I have to use the cPanel Application Manager to set up my app. I discovered the new .conf file:

<Location "/">
    <IfModule mod_env.c>
        SetEnv "PassengerRuby" "/usr/local/bin/ruby"
        SetEnv "RackEnv" "production"
        SetEnv "RailsEnv" "production"
    </IfModule>
    
    <IfModule mod_passenger.c>
        PassengerAppEnv "production"

        PassengerEnabled on
        PassengerBaseURI "/"
        PassengerAppRoot "/home/adminxxx/webapps/assist2prod/releases-2021old/20190707101851"
        PassengerAppGroupName "adminxxx - WisdomTorontoProduction"
        PassengerNodejs /opt/cpanel/ea-nodejs10/bin/node
    </IfModule>
</Location>
<Directory "/home/adminxxx/webapps/assist2prod/releases-2021old/20190707101851">
    Allow from all
    Options -MultiViews
    Options -Indexes
    Require all granted
</Directory>

Here’s some info:

# /usr/local/bin/ruby -v
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux]

# /usr/local/ruby20/bin/ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux]

Now, when I enable the app in Application Manager I get this in the apache log file:

App 792497 output: Error: The application encountered the following error: Your Ruby version is 2.4.10, but your Gemfile specified 2.1.6 (Bundler::RubyVersionMismatch)
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/definition.rb:441:in `validate_ruby!'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/definition.rb:416:in `validate_runtime!'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler.rb:143:in `setup'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/setup.rb:20:in `block in <top (required)>'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/ui/shell.rb:136:in `with_level'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/ui/shell.rb:88:in `silence'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/local/share/gems/gems/bundler-2.2.27/lib/bundler/setup.rb:20:in `<top (required)>'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/phusion_passenger/loader_shared_helpers.rb:365:in `activate_gem'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/phusion_passenger/loader_shared_helpers.rb:221:in `block in run_load_path_setup_code'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/phusion_passenger/loader_shared_helpers.rb:529:in `running_bundler'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/phusion_passenger/loader_shared_helpers.rb:220:in `run_load_path_setup_code'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/rack-preloader.rb:91:in `preload_app'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/rack-preloader.rb:189:in `block in <module:App>'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/phusion_passenger/loader_shared_helpers.rb:382:in `run_block_and_record_step_progress'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/rack-preloader.rb:188:in `<module:App>'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
App 792497 output:     /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
[ E 2021-10-15 17:49:04.3920 983139/T8j age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /home/adminxxx/webapps/assist2prod/releases-2021old/20190707101851: The application encountered the following error: Your Ruby version is 2.4.10, but your Gemfile specified 2.1.6 (Bundler::RubyVersionMismatch)
  Error ID: cf24ad74
  Error details saved to: /var/run/ea-ruby24-passenger/passenger-error-cRgyLU.html

So, I’m wondering what is going on:
Does this package force itself to be used by passenger, i.e., overriding PassengerRuby?
Have I misconfigured or missed some setting or env variable?
Am I asking the right questions?
All help appreciated!!!
It’s been a month now, and server admins keep telling me I’ve not configured the paths correctly, etc., but my stomach tells me to write you instead! (Thanks JP!)

2

Answers


  1. You have put PassengerRuby in the ENV section of your .conf file. It’s not an ENV variable, but a setting for mod_passenger.c.

    This should work better:

    <IfModule mod_passenger.c>
        ...
        PassengerRuby "/usr/local/bin/ruby"
        ...
    </IfModule>
    
    Login or Signup to reply.
  2. I think the issue you are having is in your Gemfile based on the error in Passenger. The line:

    App 792497 output: Error: The application encountered the following error: Your Ruby version is 2.4.10, but your Gemfile specified 2.1.6 (Bundler::RubyVersionMismatch)
    

    Try either changing ruby "2.1.6" to ruby "2.4.10" from the top of the file, or just remove the line from your Gemfile and run bundle install or bundle update.

    The issue is that when you specify the ruby version in your Gemfile, I think it will override the version you have in the system when installing the gems.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search