Open
Description
Problem
Installing rustup via the bash command messed up my .bash_profile.
The installer truncated the line [ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
to [ -f "$HOME/.cargo/env" ] &&
(which is now applying the conditional to some unrelated line) and then appended . "$HOME/.cargo/env"
to the end of the file.
Here it is as a patch, my original file in red(-) and the rustup installer's modifications in green(+):
--- a/.bash_profile
+++ b/.bash_profile
@@ -1,7 +1,6 @@
[[ $- == *i* ]] && [ -f ~/.bashrc ] && source ~/.bashrc
-[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
-
+[ -f "$HOME/.cargo/env" ] &&
# added by Anaconda3 5.0.0 installer
export PATH="/Users/bronson/anaconda3/bin:$PATH"
@@ -9,3 +8,4 @@ export PATH="/Users/bronson/anaconda3/bin:$PATH"
if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
fi
+. "$HOME/.cargo/env"
Steps
- Add this line to the start of your .bash_profile:
[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
- Install rustup via bash:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- That line has been modified ... poorly. now the conditional is mistakenly applied to whatever the next line is, and the
source
line has been moved the end of the file.
Possible Solution(s)
I wish the installer wouldn't try to modify lines it doesn't understand.
Notes
No response
Rustup version
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.59.0 (9d1b2106e 2022-02-23)`
Installed toolchains
Default host: aarch64-apple-darwin
rustup home: /Users/bronson/.rustup
stable-aarch64-apple-darwin (default)
rustc 1.59.0 (9d1b2106e 2022-02-23)