1

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?

1 Answer 1

1

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.

5
  • Thanks! I have access to the entire stack (as I have installed it myself), though I am most familiar with the Ruby app. There are more apps running here, though, so I'd prefer to configure this as lowin the stack as possible: nginx or passenger. And not (like I have now) hacked into the Bundle :).
    – berkes
    Commented May 9, 2013 at 8:44
  • When I said it is what you have control over, I was talking about as opposed to the gems you use. Gems get updated, and may overwrite your setting. The application that you write you have control over, and this type of change won't get overwritten. That was what I mean.
    – vgoff
    Commented May 9, 2013 at 17:05
  • I would probably look at adding the path to the .bashrc file then.
    – vgoff
    Commented May 9, 2013 at 18:31
  • .bashrc? the www-data user has no shell, not? Or am I missing something?
    – berkes
    Commented May 10, 2013 at 8:41
  • 1
    www-data:x:33:33:www-data:/var/www:/bin/sh on my system, and has /bin/sh as the shell for doing its work...
    – vgoff
    Commented May 10, 2013 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .