Correct way to set PATH

5 views
Skip to first unread message

Menno van der Sman

unread,
Dec 11, 2008, 8:48:41 AM12/11/08
to Phusion Passenger Discussions
The wishlist on Github mentions the following:

Some people run external commands in their Rails apps (e.g. system
("foo")). That will fail if the command isn’t in PATH. There should be
a chapter which explains what the problem is and how they can update
the PATH environment variable for Apache/Passenger.

So I have this problem and I'm very curious about the best way to
solve this. I searched for previous messages and found that SetEnv
doesn't work and a working solution involves creating a wrapper-script
which exports the PATH.

Is there a better way?

Lee Hambley

unread,
Dec 11, 2008, 9:32:41 AM12/11/08
to phusion-...@googlegroups.com
Menno,

 PATH is a unix thing, and there are two ways to set it - well, one way to set it, and you can do it in a few (two of which are 'standard') .......

the command is

export PATH="/extra/path/here:$PATH"

(which prepends "/extra/path/here" to the existing variable...)

Now, the UNIX path is set when you open your shell, by bash commands run in any of these places...

/etc/profile - System wide, shared profile
~/.bashrc
~/.bash_profile

If you put that command in either of the latter two places, it is set just for your user, just when you open a shell, if you set it system wide.. then that is preferable.

The path can, I believe be set some other how.... but I've never known how (would like too) - I have attached a link below, with an example.

My preference ( and the only sane way! ) is to set things like that in /etc/profile - so all your systems users benefit.

It is worth noting, that when using `sudo su` to switch users, when you change to the target user, you do not get that users path, unless you append a minus sign.. `sudo su -` - I do not know why this is the case, but is a common frustration for me, perhaps someone can clarify!

Further reading here: (he shows a slightly different syntax, and explains setenv)

-- Lee Hambley

2008/12/11 Menno van der Sman <menno...@gmail.com>

Lee Hambley

unread,
Dec 11, 2008, 9:46:09 AM12/11/08
to phusion-...@googlegroups.com
Menno,

 Since it looks like I managed not to be completely explicit in my last message.... if you need Apache to have access to environmental variables like the PATH you have to use Apache Env Vars....
Now, also slightly confusingly your server (workstation?) may have an envvars file, which misleadingly looks like it is related to apache, because it is under the Apache license.. but don't let that fool you, it is a system file.

On my workstation (mac 10.5.2) it is here..
  • /usr/sbin/envvars
And, on our (centos) server I can't find one... so your mileage may vary.

Hope this is contributing, at least a little!

- Lee Hambley

2008/12/11 Lee Hambley <lee.h...@gmail.com>
Reply all
Reply to author
Forward
0 new messages