Skip to content

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

@Freyjas-Hair

Description

@Freyjas-Hair

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugincompleteThe bug report does not have enough information

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions