Installation script writes malformed PATH line with ^M in ~/.zshenv
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 22h 40m
- Merged PRs (30d)
- 46
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-darwin
OS version
- Operating System: macOS 26.2
- Shell: zsh
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report identifies the official rustup installation command and ~/.zshenv as entry points, but names no repository file or test. Start by reproducing the command on macOS with zsh and inspect the generated PATH or source line for carriage-return characters. Done means a fresh zsh session provides a working cargo path without ^M.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, shell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100