rust-lang / rust-lang/rustup

Installation script writes malformed PATH line with ^M in ~/.zshenv

Open
#4,655 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug incomplete
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
22h 40m
Merged PRs (30d)
46

Description

Verification
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 ^M at the end.
  • As a result, cargo did 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 ^M characters to shell init files.
  • The generated/modified ~/.zshenv should 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.