Iain Barnett wrote:
> I've discovered that the load path is different if I run sudo, 
> specifically it doesn't pick up the value in GEM_HOME, even though `sudo 
> echo $GEM_HOME` shows the correct path.

sudo clears the environment. When you type

   sudo echo $GEM_HOME

then the whole command line is expanded by the shell (including 
replacing $GEM_HOME by the contents of the environment variable) before 
it is run, and hence sudo echo gets passed the already-expanded string.

Try these:

   sh -c 'echo $GEM_HOME'
   sudo sh -c 'echo $GEM_HOME'

to get the true picture.

However you can configure sudo to pass through certain environment 
variables (see 'man 5 sudoers'), or you can do

   sudo env GEM_HOME=$GEM_HOME gem install foo

The same question was asked recently at
http://www.ruby-forum.com/topic/214260
so there may be some more pointers in there.

Regards,

Brian.
-- 
Posted via http://www.ruby-forum.com/.