Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash does not inherit PATH from parent process (T10037) #112

Open
celticmagic opened this issue Aug 16, 2023 · 6 comments
Open

Bash does not inherit PATH from parent process (T10037) #112

celticmagic opened this issue Aug 16, 2023 · 6 comments
Labels
Bug Something isn't working Topic: Platform Integration Integration of various components within Solus Topic: Plumbing Core components

Comments

@celticmagic
Copy link
Collaborator

Enrico Lusiani (#elusian), 2021-11-25 10:42:01 UTC

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

@celticmagic
Copy link
Collaborator Author

Fabio (#livingsilver94), 2021-11-25 11:00:19 UTC

Fedora also retains $PATH in subshells. Just confirming it's a common behavior among distros.

@celticmagic
Copy link
Collaborator Author

Reilly Brogan (#ReillyBrogan), 2022-02-22 06:37:26 UTC

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.

@celticmagic
Copy link
Collaborator Author

Beatrice T. Meyers (#DataDrake), 2022-03-13 00:23:40 UTC

#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.

@silkeh silkeh added this to Solus Aug 23, 2023
@github-project-automation github-project-automation bot moved this to Triage in Solus Aug 23, 2023
@silkeh silkeh moved this from Triage to Needs More Info in Solus Aug 23, 2023
@davidjharder davidjharder added the Bug Something isn't working label Sep 17, 2023
@ermo ermo removed the Software label Jan 29, 2024
@Justinzobel
Copy link
Contributor

@ReillyBrogan was there any path forward on this?

@ermo ermo added this to the Solus 4.8 milestone May 4, 2024
@ermo ermo added Topic: Plumbing Core components Topic: Platform Integration Integration of various components within Solus labels May 4, 2024
@github-project-automation github-project-automation bot moved this from Needs More Info to Done in Solus Jun 10, 2024
@HarveyDevel
Copy link
Member

The fix had to be reverted: 6257780

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.

@HarveyDevel HarveyDevel reopened this Jun 25, 2024
@ermo
Copy link
Contributor

ermo commented Jun 26, 2024

I have put up #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?

@TraceyC77 TraceyC77 removed the State: Stale Old issue label Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Topic: Platform Integration Integration of various components within Solus Topic: Plumbing Core components
Projects
Archived in project
Development

No branches or pull requests

7 participants