why isn't my rails install using the latest version of passenger? - ruby-on-rails

I'm using VirtualBox on Windows to run an Ubuntu OS, which is running the turnkey rails package, which comes with ruby 1.8, rails 2.3.8, and passenger 2.2.5. When I first booted it up with just a vanilla rails app it worked fine, but now I'm getting the following error:
uninitialized constant PhusionPassenger::Utils::PseudoIO::StringIO
I googled this, and on the phusion/google groups it said this was an old error and to upgrade passenger, which I did with gem upgrade passenger. It said it was installing passenger 2.2.15, but it doesn't appear to be using it. I re-started the whole virtualbox and it is still giving me the same error, with the backtrace showing passenger-2.2.5.
I realize there are several layers here and plenty of places for things to go wrong, and to add to that, I'm pretty much a Linux newb. I've got some experience with rails. I'd appreciate any help.

It could well be your Apache configuration file. When Passenger installs it adds some code to the /etc/apache2/http.conf file so that Apache loads the Passenger extension. This code includes the version number so if you've changed the version of Apache you'll need to modify this file. The code you're looking for looks like this
LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /opt/local/bin/ruby
You'll have to be authenticated to edit the file so open a terminal window and type
sudo gedit /etc/apache2/http.conf
and enter your password to edit the file. Once you've made the changes close gedit then run
sudo /etc/init.d/apache2 restart
to restart Apache and try your Rails application again.

Try using
gem list
to make sure the new version was installed. Next to the passenger gem should see more than version listed.
You can use
gem clean
to remove old versions.

Related

Why when outside the installation directory do I get passenger: command not found?

I have just built a RackSpace cloud server with Ubuntu 12 LTS and performed a "standard" Ruby on Rails installation. I created a user (bob) and added it to the sudu group.
I then logged out of root and logged in as bob. Then issued sudo su from the /home/bob directory. I then installed everything needed to run the Rails Application 'as root'.
I then installed the Rails code in /home/bob and passenger started up when I issued:
RAILS_ENV=production passenger start -p 3000
however, since I want to run multiple Rails applications on this server, I then created another directory /home/bob/newapp and installed Rails code there. (ideally I would want to put all the different Rails applications in their own subdirectory below /home/bob)
When I issue the command (shown below) from /home/bob/newapp
RAILS_ENV=production passenger start -p 3000
I get
passenger: command not found
why is passenger only accessible from /home/bob ?
NEWS: just discovered, passenger is 'available' until the moment I complete the edit of the content of /config/database.yml thus as long as I do NOT edit the database.yml file, passenger will start. After I edit database.yml the "passenger: command not found" appears. How bizarre is that?
SNAP: looks like when I installed passenger it used Ruby-2.1.1 however the old application wants ruby-1.9.3-p194. I need to figure out how to get passenger to run with ruby 1.9.3 or install a second version of passenger (???)
More News:
Thank you,Hongli, for your response. I followed your links/suggestion to read the passenger documentation. I had read it before without recognizing the needed information. This time I found the "magical" command:
rvm-exec ruby-version ruby -S (eg: rvm-exec ruby-1.9.3-p194 ruby -S )
this has turned out to be very helpful, although I did end up following a process which has resulted in two different version of passenger being installed.
Read the About environment variables section of the Phusion Passenger manual to learn what "command not found" errors are, why they occur, and what you can generally do about them.
In your case, entering /home/bob automatically makes RVM change your PATH to include a specific Ruby version's bin directory. Read the When the system has multiple Ruby interpreters section of the Phusion Passenger manual to learn how to deal with that.
The article Hongli suggested I read definitely moved me in the correct direction.
The use of: rvm-exec 'ruby-version' ruby -S allows me to get passenger started, provided a version of passenger has been installed using the version of ruby required by the Rails application.
Thus if I load up a Rails application built with ruby-1.9.3-p194, I will need a version of passenger installed with the same version of ruby.
If I load up another Rails application built with ruby-1.9.3-p286, I will need a version of passenger installed with that version of ruby.
Then starting each version of passenger can be accomplished with the rvm-exec command with the appropriate ruby version.
Perhaps there is a more elegant solution, but the above works for me.

Passenger stand alone uses wrong ruby version?

Hello im using rails 4 with rvm - ruby verison 2.0.
But when i try to start passenger (stand alone) im getting syntax-errors.
It tells me:
Ruby interpreter command
/usr/bin/ruby1.8
How can i change it to the rvm 2.0 version?
I had the same problem: passenger standalone uses nginx, and after upgrading my app to use ruby 2.1.1 (specified in the .ruby-version), I saw similar errors.
On my production server, I know where the nginx configuration lives, so I could fix the path to the ruby interpreter.
However on the standalone setup I couldn't find it in less a minute, so I did a gem uninstall passenger followed by gem install passenger to have it recompile nginx.
Now it works, at least until the next ruby interpreter bump.
you need to use ruby first:
rvm use ruby
it might display additional instructions - make sure to read them

RVM, Passenger, NGINX on top of existing Passenger/NGINX

I previously had Passenger 2.2.13 install with NGINX 0.7.65 - I want to install rails 3 so I figured I'd go the RVM route. I followed instructions from http://blog.ninjahideout.com/posts/a-guide-to-a-nginx-passenger-and-rvm-server and am having issues because my previous install is in a different location and I think that is the one being used. When I make the changes to my nginx.conf file I get a 502 Bad Gateway on all of my apps..
Can anyone help me out with remove NGINX, Passenger, RVM, and re-installing fresh?
I am running OS X 10.6.
If the previous version was running ruby 1.8, I would do the following to have both apps running:
Install rvm
Replicate current ruby (ruby version, gems, etc) server configuration for rvm.
This is step should include re-installing passenger gem for the new ruby.
Install ruby 1.9 using rvm and then follow this guide: http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/
I've done this using apache, and now everything is working ok.
This has to do with using RVM and Passenger, passenger by default only has one path for ruby,once updated this worked fine. I've moved away from Passenger locally to avoid dealing with multiple environments.

Rails error 500 on local mac

Ok, I'm a noob with rails... so I just set up rails with RVM and created a new project, and when I try to visit a newly created view I'm getting an error 500.
Heres my setup:
OSX 10.6.5
Installed MySQL 64bit
RVM installed ruby 1.8.7 and rails 2.3.8 (no other rails or ruby except for the system ruby) rvm install 1.8.7, rvm use --create 1.8.7#rails2, gem install rails -v=2.3.8
Passenger with Apache gem install passenger, rvmsudo passenger-install-apache2-module
Passenger preference pane
Turned on websharing
I then proceeded to setup a rails project in my development folder called testapp, added it in the passenger preference pane, and then ran script/generate controller Say, defined an action hello, and then created a view in the app/view/say folder called hello.
Now I'm getting a 500 error when visiting myapp.local/say/hello, what am i doing wrong?
UPDATE:
I checked the logs and also tried running using WEBrick instead of passenger and apache. I got thrown back the same errors. I don't think I should post the entire log, should I? But the first error is
no such file to load -- sqlite3
I have not yet setup a db, I was going to use mysql, but I didn't want to install it since I'm not using models yet. Is it a requirement?
UPDATE 2:
So I installed the mysql gem with gem install mysql -- --include=/usr/local/lib (not sure if this is right). I then created a rails app with rails -d mysql myapp. And set the password in the database.yml. I'm getting a new error now:
Unknown database 'myapp_development'
So I have to create a database. Why am I being forced to create a db at all?
Yeah, you need to install sqlite even if you're not using models yet - Rails checks to make sure whatever is specified in database.yml is actually there to use.
Don't access it through passenger, launch it using ruby script/server and check out the error it throws there. Generally those errors are way more descriptive than Passenger because Passenger is probably running your application using the production environment.
Hey Ryan, do you need to Ruby 1.8.7? Why don't you install the latest 1.9.2 and Rails 3? I have the same environment and so far no problems. Here is a link for installing everything you need. Let me know if it helped! http://amerine.net/2010/02/24/rvm-rails3-ruby-1-9-2-setup.html
Salud!

Passenger with Nginx cannot find rails 2.3.8 gem

I have been trying to setup nginx with passenger for a few days now and keep running into problems. When I go to my Rails application with my browser it says: Missing the Rails 2.3.8 gem. Please gem install -v=2.3.8 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
If I type gem list in my terminal it shows: rails (3.0.0, 2.3.8, 2.3.5)
What is funny is that passenger will find my ruby gems just fine when I use it with Apache on the same machine! But I would like to experiment with nginx because Apache is not doing what I want.
The machine is Ubuntu 10.04 Server
which ruby Shows: /usr/local/bin/ruby (REE)
These are the passenger directives in the nginx.conf:
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.15;
passenger_ruby /usr/local/bin/ruby;
#Nik Rishav is correct in that you have to be careful when installing Ruby Enterprise Edition (REE) along side the system Ruby. Installing REE incorrectly can cause some very strange things to happen.
While Rails 3.0 could be the cause of your issues, my gut tells me your real issue is one missed step when installing REE. But, just-in-case this doesn't work, a quick Google search will show you any number of good tutorials showing you how to host a Rails app with Phusion Passenger for Nginx. Well, let's give it a go, shall we!
REE runs fine alongside system Ruby, but you have to install it into its own directory. For example:
/opt/ruby-enterprise-X.X.X/bin/ruby
Your other option is to only install REE, but this might not be an option for you. I suspect that when Nginx runs, it does find REE as you have specified it. Did you install Passenger for Nginx from the REE stack?
/opt/ruby-enterprise-X.X.X/bin/passenger-install-apache2-module
If you haven't, you might want to look into that. I'll assume you did.
From your description, it doesn't look like you have told REE where to find your gems. To do this, you need to set REE as the default Ruby Interpreter. To do this, add an entry to the file /etc/environment. On Ubuntu, the directory is /etc/environment. Add REE's bin directory to the PATH environment variable, like this:
PATH="/opt/ruby-enterprise-x.x.x/bin:/usr/local/sbin:/usr/local/bin"
Placing REE first in the PATH will set it as the default Ruby interpreter.
Then restart Nginx, like so:
sudo /etc/init.d/nginx restart
Hopefully this helps. I've had my share of deployment issues and it truly can be frustrating. Wouldn't wish it on anyone...Good luck!
As a check, are you sure your passenger is installed in the correct version of ruby. basically
Both the rubies have separate gems meaning you have to install the other in one..
Check in the /usr/local/lib/ruby/gems/1.8/gems Directory to see if rails 2.3.8 is present. You need to install it in the this ruby.
Both rubies will have separate gem bin files for installation..
possibly /usr/bin/gem is for the system ruby
and /usr/local/bin/gem is for your installation of REE

Resources