[ubuntu-nz] A question about how PATH works in ubuntu
Michael Hudson
michael.hudson at canonical.com
Wed Mar 11 01:10:05 GMT 2009
Tim Uckun wrote:
> I ran into a weird situation when trying to set up jruby on my machine. Here
> is the scenario.
>
> I installed jruby in /opt/jruby-1.1.6
> I created a symlink to /opt/jruby from that directory.
>
> I went into /etc/profile.d and created a file called jruby.sh (chmod +x). It
> looks like this.
>
> PATH="$PATH:/opt/jruby/bin"
>
> I log in as myself and type jruby --help and it all works.
>
> I do a "sudo jruby --help" and it says command not found.
>
> I do a su -h and the path looks fine. Take a look at the following
> transcript.
>
> tim at tim-laptop:~$ cat /etc/profile.d/jruby.sh
> PATH="$PATH:/opt/jruby/bin"
> tim at tim-laptop:~$ jruby -v
> jruby 1.1.6 (ruby 1.8.6 patchlevel 114) (2008-12-17 rev 8388) [i386-java]
> tim at tim-laptop:~$ sudo jruby -v
> sudo: jruby: command not found
> tim at tim-laptop:~$ su -
> Password:
> root at tim-laptop:~# echo $PATH
> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/jruby/bin
> root at tim-laptop:~# exit
> logout
> tim at tim-laptop:~$ su
> Password:
> root at tim-laptop:/home/tim# echo $PATH
> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/jruby/bin
> root at tim-laptop:/home/tim# exit
> exit
> tim at tim-laptop:~$ echo $PATH
> /home/tim/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/jruby/bin:/opt/jruby/bin:/opt/jruby/bin
> tim at tim-laptop:~$
>
>
> What is going on here? How come I can't sudo jruby? Where should I put this
> path so it works with sudo?
>
>
https://bugs.edge.launchpad.net/ubuntu/+source/sudo/+bug/50797 seems
relevant.
Best workaround I saw: ln -s /opt/jruby/bin/jruby /usr/local/bin/jruby
Cheers,
mwh
Cheers,
mwh
More information about the ubuntu-nz
mailing list