I am totally new to Rust and I wanted to install it. I followed the installation guide on the website. I use Linux Mint, thus I ran the following in a terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After this, when I open a new terminal, the bash: export: `/home/user/.cargo/env': not a valid identifier message appears on top of the terminal.
I figured out it is due to the following line which has been added during the installation in the .bashrc file:
export PATH=$PATH:$HOME/.local/binsource "$HOME/.cargo/env"
In the end, I solved the identifier error changing the previous line in the .bashrc file with this:
export PATH=$PATH:$HOME/.local/binsource:$HOME/.cargo/env
I open this issue because I think fixing this in the installation procedure could help some new inexperienced user (like me) facing it at the end of the installation procedure
@roxennnn what is your .bashrc content before installing with rustup ?
In specific, do you have any export PATH line in .bashrc and what is it ?
Can someone move this to rustup repository ?
In the end, I solved the identifier error changing the previous line in the
.bashrcfile with this:export PATH=$PATH:$HOME/.local/binsource:$HOME/.cargo/env
That seems wrong. I believe it should be:
export PATH=$PATH:$HOME/.local/bin
source "$HOME/.cargo/env"
@lzutao No, I didn't have any export PATH in the .bashrc file before the installation.
That seems wrong. I believe it should be:
export PATH=$PATH:$HOME/.local/bin source "$HOME/.cargo/env"
What is the difference? The wrong one seemed to work fine.
What is the difference?
The wrong one append $HOME/.local/binsource and $HOME/.cargo/env to PATH. $HOME/.cargo/env is not a directory but a script, so I think it should be sourced instead.
The wrong one seemed to work fine.
I don't know why the wrong one worked fine. Maybe cargo or rustc (or other commands you were trying) was already in your old PATH. Note that the wrong one is valid bash syntax so bash wouldn't complain.
Sounds like the the initial .bashrc didn't have a trailing newline?
Can someone move this to rustup repository ?
@ehuss maybe?
Sorry, I don't have permission to transfer to that repo.
I know there have been several PRs related to this recently (https://github.com/rust-lang/rustup/pull/2616 https://github.com/rust-lang/rustup/pull/2634).
@roxennnn Would you mind closing this and reopening it at https://github.com/rust-lang/rustup/issues/?
maybe @pietroalbini could make it ?
Transferred the issue!
Thank you Pietro. It looks like @roxennnn had a .bashrc whose last line lacked a newline at the end.
I think it's definitely a bug that we don't cope gracefully with this and so I'll add this to the 1.24.0 milestone to fix.
This is not closed.
I just had the exact same issue on Big Sur after running the indicated curl script from https://rustup.rs
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Last login: Sat Apr 10 19:07:26 on ttys018
-bash: export: `/Users/zav/.cargo/env': not a valid identifier
FYI, I've now run the installer 3 times.
Finally, this line below is written into my .bash_profile and I no longer have the error.
source "$HOME/.cargo/env"
_Is an older version of the installer installed on one of your load balancers?_
Platform: MacOS Big Sur, 11.2, M1 Mac Mini.
@azav Unfortunately there's no way in a PR to label an issue rather than close it. The bug is fixed it's just not released yet.
This will be fixed in 1.24 which we hope to release fairly soon.
Most helpful comment
Sounds like the the initial
.bashrcdidn't have a trailing newline?@ehuss maybe?