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

PATH not set post installation on OS X 10.11.4 #371

Open
slayerjain opened this Issue Apr 28, 2016 · 12 comments

Comments

@slayerjain
Copy link

slayerjain commented Apr 28, 2016

The installer said it would set the path, after installation, but even after installation there's no sign of rustup.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Apr 28, 2016

I've made some changes to this code recently, so I wonder if it broke.

For reference, here's the post-install text:

To get started you need Cargo's bin directory in your `PATH`
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run `source ~/.cargo/env`.

So what's supposed to happen is that next time you log out of the OS (or reboot), the cargo, rustc, rustup etc. commands should work. Your ~/.profile file should have a line in it now modifying PATH that the OS reads during login.

Have you logged out and logged back in yet? If you do that do the commands work? Was it unclear that you needed to log out?

@mxhold

This comment has been minimized.

Copy link

mxhold commented May 14, 2016

Ah I was confused by the same thing.

I've installed other tools in the past that on post-install try to add to the PATH automatically by appending to ~/.bashrc or some other file that is read whenever a new shell is started (rather than just on login). So I opened a new shell, tried to run cargo, and it failed. I checked ~/.bashrc, ~/.zshrc, and ~/.zshenv (where I usually append to PATH), saw nothing was at the bottom, and then assumed something went wrong and rustup did not attempt to add anything to my PATH.

To make matters worse, since I'm using zsh as my shell, ~/.profile would not be loaded even if I did login again.

I think it might be clearer if the post-install text at least indicated how rustup added Cargo's bin directory to the PATH since it can be done in many ways and not all shells load ~/.profile on login. This would allow users to correct the file and add the EXPORT to the right file.

Alternatively, rustup could entirely avoid appending to any file and just alert the user on post-install that it's up to them to add the Cargo bin directory to their PATH. While this requires more effort on the user, it seems less likely to cause problems.

Thanks for your work on rustup by the way! It makes installing rust even easier. =)

@Digipom

This comment has been minimized.

Copy link

Digipom commented May 18, 2016

I can confirm this is an issue for me as well; Terminal is reading ~/.bash_profile, not ~/.profile. This seems to be true even after logging out and logging back in.

@Digipom

This comment has been minimized.

Copy link

Digipom commented May 18, 2016

I checked what MacPorts does as they need to update the path as well:

  • If the shell is tcsh, then it will use setenv to update the path, otherwise, if the shell is bash, then it'll use export, otherwise the install script fails..
  • If using tcsh, then it will export to .tcshrc first if it exists, otherwise .cshrc, otherwise .tcshrc if neither exist.
  • If using bash, then it exports to .bash_profile if it exists, otherwise .bash_login, otherwise .profile if the first two don't exist.

I'm not as familiar with linux; would this logic make sense there, too? The man page for bash on OSX says that

After reading [/etc/profile], it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

I also found this helpful: http://stackoverflow.com/questions/18773051/how-to-make-os-x-to-read-bash-profile-not-profile-file

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Jun 23, 2016

For some reason I recall having difficulties detecting the user's preferred shell, like maybe SHELL wasn't set when piping curl | sh, not sure.

Since it doesn't hurt to append to PATH redundantly I'm still a bit in favor of appending to every relevant file we can locate that already exists, plus unconditionally appending to ~/.profile (which still seems to be the most correctish file to put this). The downside I see to this is that it could look a bit WTF for the installer to say 'I just appended the same crap to 5 files'.

@tafia

This comment has been minimized.

Copy link

tafia commented Jul 3, 2016

I confirm the issue on my system as well

@brson brson changed the title PATH not set post installation on OS X 10.11.4 Setting PATH through .profile is unreliable Jul 8, 2016

@brson brson changed the title Setting PATH through .profile is unreliable PATH not set post installation on OS X 10.11.4 Jul 8, 2016

@Frijol

This comment has been minimized.

Copy link

Frijol commented Jul 16, 2016

not working for me either, on OSX 10.10.5

@durka

This comment has been minimized.

Copy link
Contributor

durka commented Sep 29, 2016

On my system the installer updates ~/.profile but my shell runs ~/.bash_profile. Maybe rustup could internally start a new shell, see if the PATH modification worked, and if not back out the change and say "sorry, I tried, but you need to figure out where to put source $HOME/.cargo/env"?

@mikeyb

This comment has been minimized.

Copy link

mikeyb commented Oct 17, 2016

In the same boat it seems. Need to write to ~/.zprofile but don't see the option to

@johnthagen

This comment has been minimized.

Copy link
Contributor

johnthagen commented Oct 24, 2016

I have the same issue on 10.11.6, .bash_profile rather than .profile needed to be updated.

@dylanmc

This comment has been minimized.

Copy link

dylanmc commented Mar 8, 2017

I just had this problem on 10.12.3. The tools get installed in ~/.cargo/bin, and that directory is in my PATH, but the installer fails with this message.

@F1ks3r

This comment has been minimized.

Copy link

F1ks3r commented Mar 10, 2017

Quick fix:

  1. open terminal
  2. go to preferencies
  3. choose your profile (default)
  4. open tab called "Shell"
  5. add run command on start "source $HOME/.cargo/env"

if your terminal configured to your username and you are an admin this should work, but this is just a quick fix

My OS is 10.11.5

Also check what profile you are using, you can configure one and might end up using some other.

I see that that's the case to some people, so if you use .bash_profile instead of .profile, or the other way around (or any profile for that matter).

Just put export PATH="$HOME/.cargo/bin:$PATH" in your profile.

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.