how do I add global Environment Variables in Gentoo?
5,437
Solution 1
See http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=5 : you need to run env-update
so that your file gets merged into /etc/profile.env
.
Solution 2
If you created the file /etc/env.d/00example
, it would only get set when you attempt to run the command example
. Are you sure you aren't looking for setting variables in /etc/env.d/99local
(or /etc/profile)?
Related videos on Youtube
Author by
blippy
Updated on September 18, 2022Comments
-
blippy over 1 year
I know they get read from /etc/env.d/ but I tried adding in my own file in there (
00example
) with a single env variable but they aren't picked up after either env-update.How does a user declare them globablly and why did my method not work?
linux 3.0.6
-
chickenkiller over 12 yearsthe file name has nothing to do with commands typed later.
/etc/env.d
is only used to organise global environment variables in several files for clarity. -
blippy over 12 yearsI ran env-update nothing happened.
-
chickenkiller over 12 yearswhat about
env-update && source /etc/profile
? Check that your variable is stored in/etc/profile.env
... -
blippy over 12 yearsmaybe - what's 99local? It's not in my system at the moment
-
Jon Lin over 12 yearsIt's what the docs say to stick system wide user variables, but chickenkiller is right, the names doesn't matter, just the order that they get created/appended. Out of curiosity, what variable did you attempt to set?
-
chickenkiller over 12 yearsalso, make sure the files starts with 2 real digits (
0
and notO
for example), the python code that parses your file is touchy about it... see github.com/funtoo/portage-funtoo/blob/stable/pym/portage/util/… -
blippy over 12 yearsthat worked cheers - what's the reason?
-
chickenkiller over 12 yearsmaybe your
/etc/profile
is not sourced at boot... did you log in as root? Maybe/etc/profile
is handled differently for root user... Not sure... -
chickenkiller over 12 yearsIf the variable is not visible at startup without a manual
source /etc/profile
, even as root, it shows something goes wrong. At least not like you want it to behave. So maybe try to edit /etc/profile and addset -x
before the/etc/profile.env
handling stuff, andset -x
after it... Then see what trace is given at a root login... You could put it on pastebin.com so I can have a look. -
DrColossos over 12 yearsThe file
/etc/profile
is only read when a login shell is starting up. Changes to it will not take effect automatically; you need to log in again, or dosource /etc/profile
manually. -
chickenkiller over 12 yearsTotally agreed. The suggestion was to see whether we actually source it or not at a login shell startup. Are you suggesting that a root login is not seen as an interactive login?