Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] This HAS to be a stupid question about $PATH
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
dspahn
Guru
Guru


Joined: 22 Jun 2006
Posts: 360

PostPosted: Tue Nov 17, 2015 10:21 pm    Post subject: [Solved] This HAS to be a stupid question about $PATH Reply with quote

I am running Gentoo, and am having a hard time with my $PATH variable. There is something stupid I am missing but I don't know what. I installed userland tools that support the Rpi hardware platform I am using- they install to /opt/vc/bin. Then I set $PATH by adding the following line to ~/.bashrc (The only line in the file)
Code:
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/armv7a-hardfloat-linux-gnueabi/gcc-bin/4.9.3:/opt/vc/bin


Then I reboot, log back in as root (still working on the OS install) and try the command- Can someone please help me understand the results below:
Code:
RPiGen2 ~ # /opt/vc/bin/vcgencmd measure_temp
temp=49.2'C
RPiGen2 ~ # vcgencmd measure_temp
-bash: vcgencmd: command not found


As always, I appreciate your help!


Last edited by dspahn on Wed Nov 18, 2015 4:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
alinefr
Tux's lil' helper
Tux's lil' helper


Joined: 05 Jul 2009
Posts: 112
Location: São Paulo, Brasil

PostPosted: Tue Nov 17, 2015 10:33 pm    Post subject: Reply with quote

Is ~/.bashrc from your home or from root? It seems like you are trying to run it as root.

Before executing it check the output of
Code:
echo $PATH
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10261
Location: Somewhere over Atlanta, Georgia

PostPosted: Tue Nov 17, 2015 10:53 pm    Post subject: Reply with quote

Not really a stupid question, just a kind of a stupid implementation choice. The Gentoo Stage3 tarballs do not contain the requisite files that allow .bashrc to be recognized and executed for the root user. Actually, just one file is necessary, .bash_profile, but for consistency's sake, best to get the set. Run
Code:
cp /etc/skel/.??* /root
to get 'em. Note that this will copy over your existing .bashrc; might want to save it somewhere. Take a look at the default .bashrc (as it has some extra code you should preserve) and merely add your path modification to that.

Also, it's best to merely modify the path rather than replace it. Try
Code:
export path ${PATH}:/opt/vc/bin
instead.

Finally, although setting a custom path in ~/.bashrc is totally legitimate, the Gentoo Handbook Environment Variables section shows how to make global changes to the path that affect all users. Just FYI. ;)

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
dspahn
Guru
Guru


Joined: 22 Jun 2006
Posts: 360

PostPosted: Wed Nov 18, 2015 12:39 am    Post subject: Lol guess that's what I get for working across distributions Reply with quote

Thanks for the info- all of it very helpful! Going to work on this tonight.
Back to top
View user's profile Send private message
dspahn
Guru
Guru


Joined: 22 Jun 2006
Posts: 360

PostPosted: Wed Nov 18, 2015 4:01 pm    Post subject: Next Question.... Reply with quote

Thanks again for your help- I went to the Gentoo handbook and checked out setting global env variables. There is a file
Code:
/etc/env.d/04raspberrypi-userland
that contains the following:
Code:
PATH="/opt/vc/bin"
LDPATH="/opt/vc/lib"

But the PATH and LDPATH values never show for root or non-root users. I worked around it by using an export statement in the ~/.bashrc file, but I'd rather not have to do this for non-root users- Any ideas why? I checked by logging out, logging in as root and typing
Code:
echo $PATH
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10261
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Nov 18, 2015 4:03 pm    Post subject: Reply with quote

Yes. There's a different environment variable for the root path, named ROOTPATH, naturally enough.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
dspahn
Guru
Guru


Joined: 22 Jun 2006
Posts: 360

PostPosted: Wed Nov 18, 2015 4:37 pm    Post subject: And for the non-root user... Reply with quote

Why doesn't the LDPATH variable from the 04raspberry-userland file in /etc/env.d show when I (as root or non-root) type
Code:
echo $LDPATH
? I checked and the file has the same permissions as all the other files in the directory, and follows the naming convention.... Could it be that having another file whose number is 04 in the same directory is causing it to conflict or get skipped?
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10261
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Nov 18, 2015 4:44 pm    Post subject: Reply with quote

Because LDPATH is one of those "special" variables in /etc/env.d that actually doesn't become an environment variable. It's used instead to guide the rebuild of the library cache. If you run
Code:
env-update
after modifying any of those files, the cache will be rebuilt.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
dspahn
Guru
Guru


Joined: 22 Jun 2006
Posts: 360

PostPosted: Wed Nov 18, 2015 4:47 pm    Post subject: Thanks! Reply with quote

I do remember that being linked to
Code:
>>> Regenerating /etc/ld.so.cache...
messages that I think was entioned in the handbook. Thanks for the help!
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Wed Nov 18, 2015 4:59 pm    Post subject: Reply with quote

You can use /etc/bash/bashrc for system-wide settings, in general.

edit: overlap.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Wed Nov 18, 2015 6:00 pm    Post subject: Re: Next Question.... Reply with quote

dspahn wrote:
[...b]ut the PATH and LDPATH values never show for root or non-root users. I worked around it by using an export statement in the ~/.bashrc file, but I'd rather not have to do this for non-root users- Any ideas why?

dspahn ... if any additions/changes are made to env.d/* then you need to run 'env-update' and subsequently restart the shell (as a login shell) ... or 'source /etc/profile'.

Note that ROOTPATH (see: /etc/env.d/00basic) is 'unset' once PATH is exported, and the above 04raspberrypi-userland is setting $PATH for shells other than root (see: /etc/profile for PATH and ROOTPATH being appended to PATH). If you want root to also have this in their path then you also need to add ROOTPATH to 04raspberrypi-userland.

You have to wonder why it need be so convoluted, or why my PATH is polluted with '/opt/bin', and why INFOPATH (00basic) is set, when neither exist ... why make it modular and then lump it all together.

As for $PATH, I can't see why it need be hardcoded ... take the following zsh example:

Code:
% typeset -U path
% export path
% path=(/opt/bin(N-/) $path)
% echo $path
/home/khayyam/bin /usr/local/bin /usr/bin /bin /usr/i686-pc-linux-gnu/gcc-bin/4.9.3
% echo $PATH
/home/khayyam/bin:/usr/local/bin:/usr/bin:/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.9.3

... in the above $path is an array used to populate $PATH, you can make a test on the asignment being a directory '(N-/)' ... if it doesn't exist its null.

best ... khay
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum