-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
Description
Verification
- I searched for recent similar issues at https://github.com/rust-lang/rustup/issues?q=is%3Aissue and found no duplicates.
- I am on the latest version of Rustup according to https://github.com/rust-lang/rustup/tags and am still able to reproduce my issue.
Problem
During Rust installation via the official rustup script, a malformed PATH line with an appended ^M (Carriage Return) was added to my ~/.zshenv. This caused the cargo path to be incorrectly set.
result was: zsh: command not found: cargo in macos tahoe
Steps
I installed Rust/Cargo as described on the website with:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
and used the installer's default settings.
- The script modified my
~/.zshenv. - The added PATH line (or line sourcing
$HOME/.cargo/env) contained the pesky^Mat the end. - As a result,
cargodid not work in new zsh sessions (path not properly set).
Possible Solution(s)
- The installation script should use only correct Unix line endings (LF) and not write
^Mcharacters to shell init files. - The generated/modified
~/.zshenvshould contain directly functional PATH/source lines.
Notes
I figured out the root of the problem by running:
echo "$PATH" | cat -v
This revealed a ^M character at the end of the $PATH variable.
To fix it, run:
dos2unix ~/.zshenv
Rustup version
rustup 1.28.2 (e4f3ad6f8 2025-04-28)Installed toolchains
Default host: aarch64-apple-darwin
rustup home: /Users/x/.rustup
installed toolchains
--------------------
stable-aarch64-apple-darwin (active, default)
active toolchain
----------------
name: stable-aarch64-apple-darwin
active because: it's the default toolchain
installed targets:
aarch64-apple-darwinOS version
- Operating System: macOS 26.2
- Shell: zsh