packages
packages copied to clipboard
Bash does not inherit PATH from parent process (T10037)
I'm not sure if this counts as a bug, but it was for sure an unexpected behaviour.
Due to the configuration in the default bashrc, currently the PATH is reset every time bash starts.
For example if I do
export PATH=/stuff:$PATH
bash
echo $PATH
PATH will not contain /stuff anymore.
This is caused by the file in /usr/share/defaults/etc/profile.d/10-path.sh, which is sourced at the start of bashrc.
As far as I could tell this behaviour has been like this since the first commits in bash and baselayout (where I believe the default bashrc resides), so I can't find a real motivation for why Solus does this.
I would expect the PATH variable to behave like the rest of the environment and propagate to the child processes.
I'm not sure how other distros do it (I verified it works in Ubuntu and Manjaro), possibly they reset the PATH only on login shells
Fedora also retains $PATH in subshells. Just confirming it's a common behavior among distros.
I think this is a #DataDrake issue, because the last time I saw discussion about how profile.d should work (back when we had the GVFS/Hexchat issue) she had strong opinions on the topic.
I'm unsure if the solution is to modify the 10-path.sh script to only try to set an initial path if the PATH variable is unset (at which point any other profile.d script that appends to the path needs to be updated as well to be smarter about that) or subshells shouldn't be sourcing profile.d in the first place.
#ReillyBrogan I'd need to see a little more testing related to this. What does PATH look like after a reboot without 10-path.sh at all, for example.
In general, I agree that subshells should inherit an existing PATH the initial PATH should only contain things we want. I'm just not sure how best to go about this.
@ReillyBrogan was there any path forward on this?
The fix had to be reverted: https://github.com/getsolus/packages/commit/625778085ad79af84209375b02a4d12904046e1b
PATH was seemingly never being set. /usr/local/bin:/usr/bin:/bin appears to be set before 10-path.sh is sourced resulting in no changes to PATH ever occuring and /usr/sbin not being in PATH.
I have put up https://github.com/getsolus/packages/pull/3096 for testing and for inspiration.
It's possible that the sane thing to do here is to set the very basic paths up in a systemd environment file, and then do logic for each officially supported* shell that takes into account existing PATH contents when updating the PATH (which is what the PR above does for bash).
*: I don't think we actually have any policy on which shells we officially support?