Problem :
I have a server with nginx and Passenger serving a Ruby on Rails app. It uses Bundler.
Somewhere in this stack, the $PATH
gets set to /var/www/APPNAME/shared/bundle/ruby/1.8/bin/
. This directory contains, indeed, executable gems.
But I need my application to also have /usr/bin
available in its $PATH
. More specific: I need it to be able to run idendtify
, convert
and mogrify
; imagemagick commands.
For now, I have symlinked these imagemagick binaries from /var/www/APPNAME/shared/bundle/ruby/1.8/bin/
:
ls /var/www/APPNAME/shared/bundle/ruby/1.8/bin/ -ahl
#...
lrwxrwxrwx 1 root root 16 May 8 16:22 convert -> /usr/bin/convert
-rwxr-xr-x 1 ber root 379 Jan 11 08:58 erubis
#...
It’s more of a quick hack than an actual solution, though.
How can I assign extra directories to $PATH
? And where should I do that? Passenger, nginx, the Rails app?
Solution :
The ruby options are a good way to do this. Specify that the $LOAD_PATH have /usr/bin.
-Idirectory specify $LOAD_PATH directory (may be used more than once)
It is what it is there for, after all.
Another thing you can do is push the directory onto the $: global psuedo-variable.
$:.push("/usr/bin")
This would fit wherever you have your environment customization in your application.
I would probably do this for the Rails Application itself, as that is where you are concerned about it. It is what you have control over.