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)?

Share:
5,437

Related videos on Youtube

blippy
Author by

blippy

Updated on September 18, 2022

Comments

  • blippy
    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
    chickenkiller over 12 years
    the 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
    blippy over 12 years
    I ran env-update nothing happened.
  • chickenkiller
    chickenkiller over 12 years
    what about env-update && source /etc/profile ? Check that your variable is stored in /etc/profile.env...
  • blippy
    blippy over 12 years
    maybe - what's 99local? It's not in my system at the moment
  • Jon Lin
    Jon Lin over 12 years
    It'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
    chickenkiller over 12 years
    also, make sure the files starts with 2 real digits (0 and not O for example), the python code that parses your file is touchy about it... see github.com/funtoo/portage-funtoo/blob/stable/pym/portage/uti‌​l/…
  • blippy
    blippy over 12 years
    that worked cheers - what's the reason?
  • chickenkiller
    chickenkiller over 12 years
    maybe 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
    chickenkiller over 12 years
    If 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 add set -x before the /etc/profile.env handling stuff, and set -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
    DrColossos over 12 years
    The 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 do source /etc/profile manually.
  • chickenkiller
    chickenkiller over 12 years
    Totally 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?