4 ms·
I get anxiety whenever I need to set an environment var on Linux. There are (somewhat distro-specific) ways that work properly, but the usual procedures you fin
by the__alchemist 1y ago
I get anxiety whenever I need to set an environment var on Linux. There are (somewhat distro-specific) ways that work properly, but the usual procedures you find online stops working once you reboot (or close the terminal I think?). They should add a simple env var GUI like Windows has that just works, and isn't terminal-specific. Windows has the annoyance of needing to restart the the terminal (or open a new one) for changes to take effect, but works well other than that.
- zdragnar 1y ago> but the usual procedures you find online stops working once you reboot (or close the terminal I think?) The environment isn't persistent between sessions. That means you need to make the change in a way that runs on every new session (login or new terminal window). Depending on how your system is configured: .bash_profile gets run once on every login .bashrc gets run once on every non-login new session (i.e. a new terminal window) It's typical, if using these files, to do something like this: if [ -f ~/.bashrc ]; then source ~/.bashrc fi in the .bash_profile file, putting most other things in .bashrc, such that you don't have to worry about the distinction. If you're not even using bash or bash-likes at all, but instead something like Zsh, fish, etc you'll need to set things the way they want to be set there. > They should add a simple env var GUI like Windows has that just works, and isn't terminal-specific This doesn't exist in linux, because there isn't "one place" that all possible terminals draw from. Conceivably, it's possible to write a GUI tool that reads your .bashrc file, looks for anything that resembles a variable, parses the bash code to look for ways it is set, and then present a GUI tool that could update it in common cases, but... it's way easier to just write the change in a text editor.
- petre 1y ago> Conceivably, it's possible to write a GUI tool that reads your .bashrc file What's wrong with an envfile or envdir? The envdir is kind of annoying but at least you can set permissions on the files inside it.
- zdragnar 1y agoA lot of programs and tools will try to be cute and write into your bash files for you. I was mostly waxing philosophical at that point having gotten nerd sniped by "write a gui tool for environment variables" and "environment variables like $PATH in bash files" coming together in my head.
- SAI_Peregrinus 1y agoThat applies if you use bash. If you use another shell, you'll need to use that shell's methods to set environment variables in the config(s). And probably still need to set them for bash so that bash scripts get the correct env vars. NixOS & home-manager do have functions that can set environment variables across all shells enabled via either of those systems. So I've got `programs.bash.enable = true;` && `programs.fish.enable = true;` && `home.sessionVariables = { EDITOR = "nvim"; };` in my home-manager config for example. A GUI editor for that would certainly be possible.
- jcelerier 1y agoFunny, as a primarily linux user the windows behaviour irks me to no end, it's the cause of so many recurrent problems on end-user machines with so many apps that pollute environment.. and then you wonder why something doesn't work and then it turns out that for some reason you're using $SOFTWARE from c:\Perl64\bin instead of its proper place
- NekkoDroid 1y agoOn systemd systems you can just either set KEY=VALUE pairs in `/etc/environment` or any file in `/etc/environment.d/` (and technically a few other places [0]). In theory it should be relatively easy to write a GUI for it by manually parsing the files. The application restarting part can't really be fixed, since environment variables aren't ever injected to a running process and can only be changed by the process itself (terms and conditions may apply) and even changes during runtime could be ignored since the program itself may have cached some already computed value based on the variable. [0]: https://www.freedesktop.org/software/systemd/man/latest/environment.d.html https://www.freedesktop.org/software/systemd/man/latest/envi...
- the__alchemist 1y agoGood info. I may write a script or tiny program to help with this.
- csours 1y agohttps://xkcd.com/927/ https://xkcd.com/927/ - Standards Situation: There are 14 competing ways to set environment variables on Linux We should create a universal way that just works and isn't terminal specific to set environment variables! Situation: There are 15 competing ways to set environment variables on Linux
- arcfour 1y ago...you just put them in your shell RC file?? This is much simpler than having to remember where the dang environment variables button is in "advanced system settings" or whatever awful command prompt syntax sets it permanently.