

Code: Select all
#
# *REQUIRED* The default PATH settings, for superuser and normal users.
#
# (they are minimal, add the rest in the shell startup files)
ENV_SUPATH PATH=/sbin:/bin:/usr/sbin:/usr/bin
ENV_PATH PATH=/bin:/usr/binCode: Select all
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fiTry this: https://forums.gentoo.org/viewtopic-t-1 ... ight-.htmlrab0171610 wrote:I can't see the original post, it comes up as "The topic or post you requested does not exist".
I do not think this code is used in current Gentoo systems. The Handbook says that /etc/env.d is where things are defined:rab0171610 wrote:I use systemd. I don't think systemd does anything specific with regards to path. The login program sets it to a default value from /etc/login.defs :Code: Select all
# # *REQUIRED* The default PATH settings, for superuser and normal users. # # (they are minimal, add the rest in the shell startup files) ENV_SUPATH PATH=/sbin:/bin:/usr/sbin:/usr/bin ENV_PATH PATH=/bin:/usr/bin
Code: Select all
grep -r ^PATH /etc/env.d/
/etc/env.d/50baselayout:PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin"
/etc/env.d/60llvm-9979:PATH="/usr/lib/llvm/20/bin"
/etc/env.d/60llvm-9978:PATH="/usr/lib/llvm/21/bin"Code: Select all
$ grep -r ^PATH /etc/environment.d/
/etc/environment.d/10-gentoo-env.conf:PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/21/bin:/usr/lib/llvm/20/binCode: Select all
$ grep -r ^PATH ~/.config/environment.d/
/home/equaeghe/.config/environment.d/15-path.conf:PATH=$HOME/.local/bin:$PATH
/home/equaeghe/.config/environment.d/15-path.conf:PATHE=$PATHCode: Select all
$ systemctl --user show-environment | grep ^PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/21/bin:/usr/lib/llvm/20/bin
PATHE=/home/equaeghe/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/21/bin:/usr/lib/llvm/20/bin~/.profile does not get sources (for me). But for interactive shells, I (can) use .bashrc and that works:rab0171610 wrote:Other paths can be added to this default minimal path in concatenation with :$PATH . For example, from ~/.profile:
Code: Select all
$ echo $PATH
/home/equaeghe/.config/carapace/bin:/home/equaeghe/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/21/bin:/usr/lib/llvm/20/bin
Code: Select all
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/21/bin:/usr/lib/llvm/20/bin
Code: Select all
PATH="$HOME/Programs:$PATH"Code: Select all
source .bashrcCode: Select all
/home/rab/Programs:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/21/bin:/usr/lib/llvm/20/binI'm not convinced of that. I think if you insist on setting the path or adding to $PATH in the environment directories and env files, then it is not working as you expect because you are likely doing it wrong or don't understand the order of precedence. But if you feel that developers need to spend their time looking into it for you, then sure -- file a bug report.equaeghe wrote:I'm becoming convinced Gentoo is doing something wrong here, overwriting my PATH. I guess I'll need to file a bug report.
The .bashrc approach does not work for GUI applications. I've got an update line for the PATH in my .bashrc and sorab0171610 wrote:If you want to add to it locally for a specific user, then all you have to do is set it in .bashrc using the format similar to the lines that exist in ~/.profile, as I pointed out by concatenation of your directories with the $PATH variable. You can put it in other files (.bash_profile), but just have those files sourced by your login shell or in your .bashrc . Leave the environment directories out of it for now.
[…]
Why does this very basic, standard and normally reliable method of modifying or adding a directory to your path not work for you? I am not convinced that you need to have a directory added to your path through the environment method or for only when using kmail. You either need those directories persistent for your user or you don't need them at all. Normally kmail will be always running and checking for new mail most of the time anyway.
Code: Select all
$ echo $PATH
/home/equaeghe/.config/carapace/bin:/home/equaeghe/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/21/bin:/usr/lib/llvm/20/binCode: Select all
$ ps 1359
PID TTY STAT TIME COMMAND
1359 ? Ssl 0:10 /usr/bin/kmail -qwindowtitle
$ cat /proc/1359/environ
[…]PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/21/bin:/usr/lib/llvm/20/bin[…]

Code: Select all
exec PATH="$HOME/Programs:$PATH" kmailGood suggestion. I tried that earlier and it failed (kmail does not start). The reason is likely because one isn't allowed to have a second, unquoted ‘=’ in the Exec line or the variables are not expanded. A stackoverflow post suggests calling a shell to start the application:rab0171610 wrote:Why do you not explicitly set the path in the .desktop file or whatever method that you are using to launch kmail? In my example, the exec line for the desktop file would be:Code: Select all
exec PATH="$HOME/Programs:$PATH" kmail
Code: Select all
Exec=sh -c "PATH='$HOME/.local/bin:$PATH' kmail"Thanks for the suggestion. I use the ~/.config/autostart directory (the autostarting is done by systemd), but I only ever add symlinks there to existing system or modified desktop files (the latter category indeed in ~/.local/share/applications).rab0171610 wrote:Just a note about KDE, if you are using KDE autostart to launch applications automatically at login (the desktop files are kept in ~/.config/autostart) you can add the environment variables to the entries in SystemSettings->System->Autostart . […] Otherwise, if you do not autostart kmail for some reason you can keep a modified .desktop file with the $PATH environment variable for kmail in ~/.local/share/applications .
That's not exactly accurate. The bashrc approach works for bash, and processes started by bash, unless an intervening process clears out the environment. So as flexibeast noted at the beginning, if you log in on a text console and then start a GUI, your GUI will have descended from bash, and will have variables that were set by bash.[1] Conversely, if you use a login manager such that your GUI is spawned without any bash in the ancestry tree, then bashrc will never have been in effect for the GUI.equaeghe wrote:The .bashrc approach does not work for GUI applications.
Yes. It's to work around that they bypassed the traditional method of setting environment variables, at which point they had to reinvent the wheel.equaeghe wrote:There really is a reason why desktops like KDE have functionality like the ~/.config/plasma-workspace/env location for environment variable-modification scripts for GUI apps.
You don't need the shell to expand those. Expanding those percent-specifiers is the job of whatever custom tool is parsing a .desktop file. What happens if you write:equaeghe wrote:A stackoverflow post suggests calling a shell to start the application:This works! (I still find it kludgy, as then I can't reuse the standard "kmail -qwindowtitle %c %u" invocation, as the shell cannot expand %c %u.)Code: Select all
Exec=sh -c "PATH='$HOME/.local/bin:$PATH' kmail"
Code: Select all
Exec=/bin/sh -c "PATH='$HOME/.local/bin:$PATH' kmail "$@"" -- -qwindowtitle %c %uCode: Select all
Exec=sh -c "PATH='$HOME/.local/bin:$PATH' kmail"
Code: Select all
PATH="$HOME/Programs:$PATH" kmailCode: Select all
[General]
systemdBoot=falseCode: Select all
systemctl --user status plasma-plasmashell.service
○ plasma-plasmashell.service
Loaded: masked (Reason: Unit plasma-plasmashell.service is masked.)
Active: inactive (dead)Code: Select all
Entry Handling
Hidden=, X-systemd-skip= No service will be generated if set to true
Code: Select all
#!/bin/bash
PATH="$HOME/.cups:$PATH" kmail&
login.defs(5) is a configuration file for login(1):equaeghe wrote:I do not think this code is used in current Gentoo systems.Code: Select all
# # *REQUIRED* The default PATH settings, for superuser and normal users. # # (they are minimal, add the rest in the shell startup files) ENV_SUPATH PATH=/sbin:/bin:/usr/sbin:/usr/bin ENV_PATH PATH=/bin:/usr/bin
So the contents of login.defs will be processed unless a system is not using login(1) for logging in.CONFIG FILE ITEMS
login reads the /etc/login.defs configuration file (see login.defs(5)).