I have a 3rd party eclipse-based application and I start it by double-clicking the executable. Since I need to set certain environment variables to make the application not crash on start (a known issue with eclipse in Ubuntu 22.04). I can make it work if I start the application from a terminal but when I double-click it, environment variable setting are ignored even from /etc/profile.d. So how can I set a system-wide variable that is respected by double-clicked executable that is not linked to a terminal?
Asked
Active
Viewed 82 times
1 Answers
1
The way environment variables work in unix is frequently misunderstood. There is no way to globally set an environment variable. (This has been answered before.)
Environment variables are (optionally!) inherited from the parent process at process creation, and the parent process can't change them in the child. Similarly, there is no way to globally change an environment variable for already running processes.
So this leaves you with the following ways to do what you need:
- set the environment variable initially (when the user logs in?) via shell config files or other paths
- change the program configuration to set the parameter itself at startup
- change the command to start the program (use
env var=value command...) or change the.desktopfile that starts the program or similarly wrap the program in a shell script that sets the environment variables.
If setting the variables in /etc/profile.d is "being ignored" then the profile.d files are not being run or you didn't log back in after changing them there.
user10489
- 5,533