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
Related
I'm trying to deploy a Ruby On Rails App on a shared host, that has ruby 1.9.3-p551. Phusion Passenger now returns the error message:
Rails 4 prefers to run on Ruby 2.1 or newer.
You're running
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
Please upgrade to Ruby 1.9.3 or newer to continue.
(SystemExit)
/.../my_home_directory/.../vendor/cache/gems/railties-4.2.3/lib/rails/ruby_version_check.rb:12:in `abort'
and then a big stack trace. I'm using rbenv for controlling different ruby versions. When I type in rbenv versions it says:
system
* 1.9.3-p551 (set by /my_home_directory/.rbenv/version)
ruby -v
1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
But in the error message of passenger there's the information:
General Interpreter Information
RUBY_VERSION = 1.9.2
I can't check the Apache config files because I'm on a shared host and have therefore no root rights. So I can't reinstall ruby or rubygems.
I already tried reinstalling every local gem. I typed bundle install and bundle upgrade multiple times. I tried to install a local ruby version with rbenv local 1.9.3-p551 in the home directory, the .rbenv directory, the app home and the app/public directory. I tried to change the used ruby version with rbenv shell 1.9.3-p551, and probably did some more things, I currently can't remember because I started very late to write the things down that I already did.
Why does passenger have the wrong ruby versions besides that PassengerRuby in the Apache config file is wrong? I think that's very unlikely, because I think that my hosting provider knows what he's doing. Is there something I could do to let passenger or rails use the right (installed) version?
Does anybody have an idea why passenger has the wrong ruby versions besides that PassengerRuby in the Apache config file is wrong?
Passenger author here. The fact that PassengerRuby in the config file is wrong, is the only reason why you're having this problem. The only solution is to set PassengerRuby to the right instance.
If your shared host doesn't allow you to set PassengerRuby, then I recommend that you switch to a different. Try Digital Ocean for example. They're cheap, gives you full control, and we have a full end-to-end deployment walkthrough for Digital Ocean.
I want to upgrade our Ruby version and a bunch of gems on our production website that we are currently running. We use RVM to manage our Ruby versions and gemsets.
I know how to install a new Ruby version using RVM and install gems in a gemset. I also understand that if I run bundle install it will install my gems into the Ruby version I am running the command from.
Is there some way to pre-create a Ruby version with a gemset in it and then swap my production site to use this new Ruby version and gemset? I know this can be done manually, but is there anyway to do it with a gemfile?
Yes, you can specify the Ruby version in the Gemfile:
source 'https://rubygems.org'
ruby '2.1.3'
This allows you to set the version that would be used if you deploy to Heroku, for example. Your question does not detail your production environment, so it's not clear if it can use the Ruby version in the Gemfile.
Locally, the app will run against whichever Ruby version is active with RVM. The only way to know if it will work is to run the specs against the new Ruby version. Your question did not mention specs, but if you have a complete set of specs then this is the proper way to find out if the new Ruby version will work.
You can install new versions of Ruby and gem sets all day long without it affecting a running application. Once an application is running, it continues running under the same version of Ruby the entire time.
You can have RVM install new Rubies, manipulate gemsets, etc., as long as you don't remove the version of Ruby the application needs. If the binary disappears your app might crash/lock-up if the system needs to load something that has been deleted.
This totally depends on your setup. I am anwsering for a Passenger/Apache setup.
With Passenger and Apache, you can set my PassengerRuby in the Apache Vhost file so it uses that particular version of Ruby, I would set it to your current ruby path and restart Apache like so:
PassengerRuby <path-to-ruby>
Then you you can install your new ruby version and gems, once you install everything you can change the PassengerRuby to the new ruby path and restart Apache. This should migrate your Ruby version smoothly, since you can always fallback to your old 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
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.
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.