what is an environment variable?
craigwhite at azapple.com
Sat Mar 17 01:42:40 UTC 2012
On Fri, 2012-03-16 at 20:21 -0400, Robert P. J. Day wrote:
> On Fri, 16 Mar 2012, Smoot Carl-Mitchell wrote:
> > On Fri, 2012-03-16 at 23:03 +0000, Thufir Hawat wrote:
> > > I've looked at
> > > https://help.ubuntu.com/community/EnvironmentVariables and some
> > > other resources, but it's still unclear to me *what* $PATH is.
> > > There's no corresponding file, just various files which add to the
> > > this variable. (It's a shell variable?)
> > PATH is an exported shell variable. So it shows up as part of the
> > environment in a forked process.
> just my $0.02, but i like to avoid PATH being part of the
> *environment*. it's obviously a useful *shell* variable but, if you
> think about it, its value is to locate commands based on how
> complicated you want to make your search path.
> *however*, once the command is located, it's generally safer if
> *those* commands use a standard search path, and not your overly
> complicated one. that's why you see so many people who, at the top
> of their shell scripts, have a line like:
> it's specifically to avoid having a shell script having to deal with
> an arbitrarily insane setting of PATH based on who invokes it.
> or is there some compelling reason to export PATH that i'm missing?
One of the strengths of UNIX and thus Linux is the ability to
personalize your environment and override the default
settings/executables. Seems normal on both Ubuntu and all RH derived
systems to default users with a PATH setting
of :/usr/local/bin:/usr/local/sbin:/usr/bin:/bin (and root also will
generally have /sbin within the path). The order is significant...
commands will be searched in the order specified.
This allows you to add executables for all users in say /usr/local/bin
or there are various times when I want to run say the latest version of
openldap server but some of the parts of openldap from Ubuntu need to
stay in /usr/bin so I compile & install in /usr/local/bin. This lets me
easily execute the version of slapd in /usr/local/bin rather than the
one in /usr/bin
Now the OP is trying to use rvm (Ruby Version Manager) which allows you
to install many versions of ruby on a system and easily switch between
them and to do this magic, it requires some manipulation of the PATH
environmental variable. This is because most deployments are done with
Ruby version 1.8.7 but development these days really should be done with
Ruby version 1.9.3
Anyway, there shouldn't be too much need to export the PATH for rvm
beyond the changes suggested either to ~/.bash_profile or to some file
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the ubuntu-users