All, I need to set environment variables in my ~/.profile
since I am running a program (QtCreator) that doesn't start a bash shell.
I cannot for the life of me get it to work though. QtCreator will not show any of the environment variables I defined under "System Environment."
How can I do this?
Edit: Okay, actually it turns out my question is why can't I source my_environment
where
my_environment:
export SOME_PATH=blalalal
If I add export SOME_PATH=blalalal
to my ~/.profile
it works. But I can't use source ~/.profile
Best Answer
Here is the story:
(source)
solution: export the variables defined in
.profile
.export VAR1=foo
solution: put the variables in .bashrc, open a terminal and start QtCreator from command line. It should have the variables. Don't forget to export them:
solution: create a wrapper for starting your program, a small script that you run instead of running the program directly:
or
solution: edit the
.desktop
file used to launch the application by modifying the execute line toinstead of
(haven't tested that, but it should work)
solution: change the environment. You are right in your comment that programs do get an environment, even if they do not read it from the
.profile
. The system-wide environment is in/etc/environment
, but you can also set it per session, in a file in your home directory called.pam_environment
. See here for more information. By the way, this page neatly explains what all the different files do and when to use which.However, I prefer solutions 1-3, because they change the environment of the program only, and not of the whole session.