[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

sudo ruby loosing environment?

Trans

5/19/2008 7:07:00 PM

My Ruby installation is from the Ubuntu package repository. Yesterday,
I upgraded my system to Heron and since then one of my Ruby scripts
stopped working. I traced the problem to this:

$ ruby -e"p ENV['ROLL_PATH']"
"/home/trans/Company/TigerOps/programs"

$ sudo ruby -e"p ENV['ROLL_PATH']"
nil

At first I though it might have something to do with sudo itself, but:

$ echo $ROLL_PATH
/home/trans/Company/TigerOps/programs

$ sudo echo $ROLL_PATH
/home/trans/Company/TigerOps/programs

So that's not it. Anyone have any idea what's going on?

My current version of Ruby is now:

$ ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]

Thanks,
T.

2 Answers

Gregory Seidman

5/19/2008 7:46:00 PM

0

On Tue, May 20, 2008 at 04:07:13AM +0900, Trans wrote:
> My Ruby installation is from the Ubuntu package repository. Yesterday,
> I upgraded my system to Heron and since then one of my Ruby scripts
> stopped working. I traced the problem to this:
>
> $ ruby -e"p ENV['ROLL_PATH']"
> "/home/trans/Company/TigerOps/programs"
>
> $ sudo ruby -e"p ENV['ROLL_PATH']"
> nil
>
> At first I though it might have something to do with sudo itself, but:

Yes, it's sudo. Your test is flawed.

> $ echo $ROLL_PATH
> /home/trans/Company/TigerOps/programs
>
> $ sudo echo $ROLL_PATH
> /home/trans/Company/TigerOps/programs

$ROLL_PATH is interpreted by the shell before sudo is ever invoked.

> So that's not it. Anyone have any idea what's going on?
[...]

This is unrelated to Ruby or Ubuntu. This is how sudo works. Read the
sudoers man page, looking for env_keep. You will need to edit the
/etc/sudoers file (with visudo, not directly).

> Thanks,
> T.
--Greg


Trans

5/20/2008 2:01:00 AM

0



On May 19, 3:46=A0pm, Gregory Seidman <gsslist+r...@anthropohedron.net>
wrote:
> On Tue, May 20, 2008 at 04:07:13AM +0900, Trans wrote:
> > My Ruby installation is from the Ubuntu package repository. Yesterday,
> > I upgraded my system to Heron and since then one of my Ruby scripts
> > stopped working. I traced the problem to this:
>
> > =A0 $ ruby -e"p ENV['ROLL_PATH']"
> > =A0 "/home/trans/Company/TigerOps/programs"
>
> > =A0 $ sudo ruby -e"p ENV['ROLL_PATH']"
> > =A0 nil
>
> > At first I though it might have something to do with sudo itself, but:
>
> Yes, it's sudo. Your test is flawed.
>
> > =A0 $ echo $ROLL_PATH
> > =A0 /home/trans/Company/TigerOps/programs
>
> > =A0 $ sudo echo $ROLL_PATH
> > =A0 /home/trans/Company/TigerOps/programs
>
> $ROLL_PATH is interpreted by the shell before sudo is ever invoked.
>
> > So that's not it. Anyone have any idea what's going on?
>
> [...]
>
> This is unrelated to Ruby or Ubuntu. This is how sudo works. Read the
> sudoers man page, looking for env_keep. You will need to edit the
> /etc/sudoers file (with visudo, not directly).

Ok. That makes sense. Though I don't yet understand what changed --it
was working fine before the dist-upgrade.

Thanks,
T.