Passenger (mod_rails) $PATH on Leopard / Snow Leopard

Passenger uses a little subset of your PATH.

So if you have installed ruby, gem and misc binaries in other paths you cannot access them via your passenger rails application.

Create an executable script ruby_with_env, I wrote it in my /usr/local/bin:

1
2
3
4
#!/bin/bash
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/graphviz/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin:/usr/local/git/bin/
:$PATH"
/usr/local/bin/ruby $*

Now point the file to your PassengerRuby directive in your apache configuration file and restart.

$1.99 domains with SSL purchase!

3 thoughts on “Passenger (mod_rails) $PATH on Leopard / Snow Leopard

  1. Thanks, this is very helpful — and applicable to any platform (linux, solaris).

    One point was confusing: “Now point the file to your PassengerRuby directive in your apache configuration file and restart.”

    What it means is kind of the reverse: set PassengerRuby to this new file — so the apache configuration is something like this:

    PassengerRuby /opt/local/ruby/bin/ruby_with_env

    This worked great for me with Passenger + Ruby Enterprise Edition. I had gems calling `git clone …`, and of course, git was not on the limited $PATH that Passenger was using.

  2. @David Reese
    hi David, thanks for pointing it out, as a non native english speaker stuff like this often tend to miss my double checks, I’ll enrich the post soon, which actually is very raw because I copy/pasted it from my notes.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">