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

Maybe `~/.profile` is where PATH modifications should go #211

Closed
brson opened this Issue Mar 30, 2016 · 11 comments

Comments

Projects
None yet
5 participants
@brson
Copy link
Contributor

brson commented Mar 30, 2016

@Diggsey had multirust-rs installing path modifications to ~/.profile and I changed it because ~/.profile is only read for login shells, and that seemed wrong since most shells are not login shells. I'm happy to change this to do the right thing, but I'd like to understand better why it's ok not to set the PATH for non-login shells.

Source.

@brson

This comment has been minimized.

Copy link
Contributor Author

brson commented Mar 30, 2016

As @Diggsey pointed out on IRC the main problem with ~/.profile is that it requires you to actually re-login to take effect, like from your desktop environment, not just start a new shell. This is a major pain in practice.

@matklad

This comment has been minimized.

Copy link
Member

matklad commented Mar 30, 2016

but I'd like to understand better why it's ok not to set the PATH for non-login shells.

For example if a user launches application (IDE or Emacs, for example) via desktop environment and not via command line, then the PATH will be wrong.

Please note that not all desktop managers execute ~/.profile on startup. I think it is more like ~/.profile ^ ~/.xprofile get executed. I can not point to authoritative documentation on this issue, but this thread in nixos has some info NixOS/nixpkgs#5200 (comment)

@brson

This comment has been minimized.

Copy link
Contributor Author

brson commented Mar 30, 2016

For example if a user launches application (IDE or Emacs, for example) via desktop environment and not via command line, then the PATH will be wrong.

Ah, ok, that makes a lot of sense. So it's not just cli shells then that run ~/.profile, it's whichever program does the login.

So today if you do any development not under a shell the PATH is going to be misconfigured.

Putting this into ~/.profile again will make it so that you can't just start a new shell after install, but maybe that's ok. We already have instructions after install that say how to source the correct env.

@matklad

This comment has been minimized.

Copy link
Member

matklad commented Mar 30, 2016

Putting this into ~/.profile again will make it so that you can't just start a new shell after install, but maybe that's ok.

I think I've miscommunicated the part about ~/.xprofile. Depending on your login program, either .profile OR .xprofile will be executed. So putting this just in .profile will not work for some users.

I believe there is no single place where you can robustly do PATH manipulation. And of course there are users who have something like

export PATH="/bin:/usr/bin:/home/matklad_several_years_ago/bin"

in one of their dot files, which undoes all PATH manipulation.

PATH is a global mutable static, so accessing it is unsafe :(

@Diggsey

This comment has been minimized.

Copy link
Contributor

Diggsey commented Mar 30, 2016

The nature of environment variables on linux means we can't hope to get this to "just work" in all cases: .profile will cover the majority of cases, and the remainder will have to be handled by the user. We can only assist them by telling them which directory needs to be added to the PATH.

@nodakai

This comment has been minimized.

Copy link
Contributor

nodakai commented Mar 31, 2016

I think it is the best practice to have . ~/.profile inside ~/.xprofile assuming either one of them gets executed upon starting a console/GUI session.

@jrobeson

This comment has been minimized.

Copy link

jrobeson commented Apr 1, 2016

I doubt ~/.xprofile will be read when running under a Wayland compositor or the Mir equivalent either.

@jrobeson

This comment has been minimized.

Copy link

jrobeson commented Apr 1, 2016

In any case, please don't write useless files to my $HOME without asking. I don't have or use ~/.profile (or ~/.xprofile)

@jrobeson

This comment has been minimized.

Copy link

jrobeson commented Apr 1, 2016

oh, there's already an issue for that #170

@nodakai

This comment has been minimized.

Copy link
Contributor

nodakai commented Apr 1, 2016

@jrobeson FYI, X, Wayland and Mir are display servers while it is a display manager like GDM or LightDM which typically sources .xprofile for you and then launches a window manager like fluxbox, Ubuntu Unity or GNOME shell's Mutter. I just found a nice memo on which software shipped by which Linux distro is responsible for sourcing .xprofile:

@jrobeson

This comment has been minimized.

Copy link

jrobeson commented Apr 1, 2016

i had no idea about xprofile, because I've never had any ~/.xprofile on any of my linux desktops for at least the past 8 years. I definitely don't want mulitrust to create this file that isn't at all used or required for anything else.

brson added a commit to brson/rustup.rs that referenced this issue Apr 6, 2016

Add PATH to ~/.profile instead of ~/.*rc
No transition plan for the old scheme.

Fixes rust-lang#211

brson added a commit to brson/rustup.rs that referenced this issue Apr 6, 2016

Add PATH to ~/.profile instead of ~/.*rc
No transition plan for the old scheme.

Fixes rust-lang#211

peschkaj added a commit to peschkaj/rustup.rs that referenced this issue Apr 7, 2016

Add PATH to ~/.profile instead of ~/.*rc
No transition plan for the old scheme.

Fixes rust-lang#211
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.