Do I Need to Install Passenger as a Regular Gem Even Though My App Uses Bundler

Do I need to install passenger as a regular gem even though my app uses bundler?

The application itself would run without having passenger installed (unicorn, webrick, mongrel, thin, etc.), therefore passenger shouldn't really be in the Gemfile. Installing passenger as a gem separately would be the correct choice in this instance.

Look at the Gemfile as a list of the gems that your application is using. Passenger is using your application to serve data to the user, rather than your application using it. Down the road, you may consider using another application server, and you shouldn't have to change any portion of your application, even the Gemfile, to make that change.

However, if your application is actually using passenger-specific features or portions of the passenger gem internally, then you should include it. For example, if you were using a class declared in passenger, then you would be depending on it, and should include it in your Gemfile.

Passenger misses development gem in production environment

Are you using the bundler capistrano recipes?

Make sure this is in your config/deploy.rb

require 'bundler/capistrano'

Basically it will invoke bundle with the --without development test option, which should only install the production gems. If you are just doing a regular bundle, it will install try to install the gems for all environments.

Deploy Rails 3 with Phusion Passenger on Ubuntu WITH ALL GEMS INCLUDED

  • Download the bundler 1.3.5 gem from http://rubygems.org/downloads/bundler-1.3.5.gem and put it in vendor/

  • In an Ubuntu 12.04 vm, do bundle package --all. Git commit and push.

  • Clone on the Ubuntu server.

  • apt-get install each of apache2, ruby1.9.3, etc. (not rubygems or ruby-bundler. Both provide an old version of Rubygems and Bundler. A newer version of rubygems is included in the ruby1.9.3 package.)

  • Follow ALL of the instructions in section 2.3 at http://www.modrails.com/documentation/Users%20guide%20Apache.html#install_on_debian_ubuntu

  • Make sure you have the right Ruby and Rubygems versions set to the ruby and gem commands:

update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.3 200
update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.9.3 200

(Phusion Passenger doesn't care about this, but it's probably a good idea for the gems we are about to install and for debugging stuff with the Rails console or whatever in the future.)

  • gem install --local vendor/bundler-1.3.5.gem

  • bundle install --local

  • Set up all your other Apache config...

  • service apache2 restart

how to include bundler itself when using bundle install --deployment

The reason this doesn't work is because Bundler.setup is the code that actually sets up your load path to find the vendored gems. If Bundler were vendored, it wouldn't be able to find it to do that setup.

You can do one of two things:

  1. Install Bundler as a system gem. This is the most common solution. You could build a separate RPM to install it (or maybe there's already one out there you can use) and depend on it in your app's RPM.

  2. Use Bundler's standalone mode. This will give you an application that does not depend on Bundler at all. In that case, you should remove the require 'bundler' and Bundler.setup lines from your application and instead add require_relative 'bundle/bundler/setup' (with the path adjusted if you're calling it from a file located somewhere other than the root directory of your project).

apache, passenger/rails, ruby, redmine -- rails startup / gem path problem

There were a couple of issues here. Thanks @Casper for some hints.

  1. Passenger must be installed system-wide, i.e., as root.

    It was installed as the redmine user, so had to be de-installed.
    Checking the passenger uninstall page for apache, it says
    "Remove the passenger files" and then details how to do that, assuming passenger was installed any way except from source.

    Unfortunately, I installed from source, as the regular repositories are way out of date. Uninstalling from source is non-trivial, as the passenger files are mixed in with the other application files and there is no easy way to find them all and differentiate. I ended up deleting the entire ruby / redmine environment for the user and starting over.

To install passenger as root, in a ruby-install/chruby environment:

sudo -i
cd /opt/rubies
source /usr/local/share/chruby/chruby.sh
chruby 3.0.4
gem install passenger
passenger-install-apache2-module
exit

  1. Once passenger was re-installed globally, attempting to set up redmine for a specific user still failed with the same error -- Bundler can't find any gems. I read several places that one should not have to set the GEM_PATH explicitly, as Passenger/Ruby/Bundler are supposed to be able to automatically find the gems they need if they are in a conventional place, but apparently not. My assumption was that since the passenger definition for the redmine app specified the user environment properly, they should be found. (It's not clear to me if this problem is specific to Passenger, an Apache2 installation, or Ruby/Bundler)
    The problem may be because I am using ruby-install and not rvm; passenger's docs seem to assume rvm is used as the installer.
    In any case, I had to explicitly set GEM_PATH in the apache2 configuration.
    The path is the one shown if "gem env GEM_PATH" is given from the user account.
    So for this case, in (file rubies/test_user.include above), add the line:

    SetEnv GEM_PATH /home/test_user/.gem/ruby/3.0.4/:/opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0/

The complete apache2 config fragment looks like:

<Directory /var/www/html/issues-test>
PassengerAppRoot /home/test_user/redmine_test
PassengerAppEnv redmine_test
PassengerAppGroupName redmine_test
RailsBaseURI /issues-test
PassengerUser test_user
PassengerGroup test_user
PassengerFriendlyErrorPages on
SetEnv GEM_PATH /home/test_user/.gem/ruby/3.0.4/:/opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0/
</Directory>

Keep Getting Could not find passenger (=0) amongst While Passenger

Did you make sure that passenger is in your Gemfile? I see you installed bundler and I think that is related to the ruby_noexec_wrapper in your stack trace.

Phusion Passenger Error: You have activated rack 1.2.1, but your Gemfile requires rack 1.2.2

try to restart your server after edit in your Gemfile and put this: gem 'rack', '1.2.1'

docker apache passenger: error cannot load such file bundler/setup (LoadError)

Setting GEM_HOME just patches over the real problem. This information here is your hint:

User and groups:
id=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)

Passenger is trying to run your app as the user 'nobody'. Most likely, this is not what you meant it to do. Your gem bundle is probably installed by a different user, and the 'nobody' user probably does not have access to that installed gem bundle.

Why is Passenger running your app as 'nobody'? Because of user sandboxing rules, most likely caused by wrong permissions on your app. You should fix that.

By the way, why are you building your own Docker image? Phusion provides its own passenger-docker base image.



Related Topics



Leave a reply



Submit