Greg
Greg

Reputation: 429

How to run Rails app using Apache/Passenger with Multiple Ruby versions

I'm trying to setup a Apache/Passenger configuration to allow multiple Ruby versions. I saw the post on multiple Rubies here (http://blog.phusion.nl/2013/08/19/phusion-passenger-4-0-14-released/) but apparently it's obsolete as Passenger now supports the "PassengerRuby" config in a Virtual Host. However, I'm still having troubles. What am I doing wrong?

I have an installation of Passenger (4.0.14) which is configured with

PassengerDefaultRuby /usr/local/rvm/rubies/ree-1.8.7-2012.02/bin/ruby

The server has a virtual host which has been recently upgraded to include some features which are only available in more recent versions of Rails.. so I'm trying to run Ruby 1.9.3 and Rails 3.0 for just that application.

EDIT: The application needs 1.9.3 for some specific features. But when I run it with just the PassengerDefaultRuby as 1.8.7 it works fine (except for those features). It's only when I add 1.9.3 that I have problems.

EDIT: If I specify 1.9.3 as the default Ruby, and don't specify a PassengerRuby for the application, the app doesn't work. So I'd guess I have something wrong with the 1.9.3 installation.

So.. I add

PassengerRuby /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby

When I do that, I get the following stack track in the apache2 error.log

[ 2013-09-06 07:48:32.2794 32582/7f4d0715c700 Pool2/Spawner.h:738 ]: [App 32622 stdout] 
[ 2013-09-06 07:48:35.6479 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr] [     2013-09-06 07:48:35.6477 32622/0x00000002c633e0(Worker 1) utils.rb:71 ]: *** Exception TypeError in Passenger RequestHandler's client socket (wrong argument type Array (expected Struct)) (process 32622, thread 0x00000002c633e0(Worker 1)):
[ 2013-09-06 07:48:35.6479 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/ruby_core_enhancements.rb:81:in `writev2'
[ 2013-09-06 07:48:35.6479 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/ruby_core_enhancements.rb:81:in `writev2'
[ 2013-09-06 07:48:35.6479 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/utils/unseekable_socket.rb:126:in `writev2'
[ 2013-09-06 07:48:35.6479 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/rack/thread_handler_extension.rb:130:in `process_request'
[ 2013-09-06 07:48:35.6480 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
[ 2013-09-06 07:48:35.6480 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
[ 2013-09-06 07:48:35.6480 32582/7f4d0711b700 Pool2/Implementation.cpp:1172 ]: [App 32622 stderr]   from /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
[Fri Sep 06 07:48:35 2013] [error] [client 10.100.193.133] Premature end of script headers:

Upvotes: 0

Views: 1551

Answers (2)

Greg
Greg

Reputation: 429

I received the following reply from Phusion on the phusion-passenger email list.

> Exception TypeError in Passenger RequestHandler's client socket (wrong argument type Array (expected Struct)) (process 32622, thread 0x00000002c633e0(Worker 1)):

This error indicates that your Ruby interpreter is loading a native
extension that was compiled for a different Ruby version. Try cleaning
things up:

sudo rm -rf /usr/lib/ruby/gems/1.8/gems/passenger-4.0.14/buildout/ruby
rm -rf ~/.passenger/native_support

Then restart your web server and re-access your app. Does that help?

Since I had installed as sudo, I didn't have a ~/.passenger directory. But removing the buildout/ruby directory was enough to allow my 1.9.3 application to run.

Upvotes: 1

I recently implemented Passenger 4.0.10 using different versions of Ruby (1.9.3 & 2.0.0). Here are some things to check:

Have you installed the Passenger gem in each RVM gemset? When I was having problems with this I was advised to do this by the Passenger team.

Did you check out the RVM Helper Tool for PassengerRuby in the documentation? Here is the link for the PassengerRoot Documentation from Passenger. You probably have the wrong value for PassengerRuby. You will need to execute the which passenger-config command in each gemset to get the correct command to execute for passenger config. There are two sections in the output of passenger-config --ruby-command which mentions values for PassengerRuby. I used the value mentioned in the first section in the output in my virtual host config file.

Note: Sometimes RVM for me can be a nightmare :) I had to look at the RVM Helper Tool documentation several times (and several failed attempts) before getting this to work.

Upvotes: 0

Related Questions