-
Notifications
You must be signed in to change notification settings - Fork 983
Description
Verification
- I searched for recent similar issues at https://github.com/rust-lang/rustup/issues?q=is%3Aissue+is%3Aopen%2Cclosed 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
When 'rustup' is run within Cygwin environment on the Windows, it detects x86_64-pc-windows-msvc
as default host. One would expect x86_64-pc-windows-gnu
on Cygwin where gcc is typical primary toolchain. This can be handled by passing --default-host
to install script so it is really minor problem but IMHO a little bit of inconvenience, depending on how one looks into it.
Also...
When one tries to pass CARGO_HOME and RUSTUP_HOME variables to control where rust should be installed within Cygwin environment on Windows and user sets absolute paths for these variables, installation script "mangles" these paths by prefixing them with "C:/" making them invalid (setting up rust somewhere "outside" of the Cygwin environment, typically in the C:\ root which is not what user really wants.
Steps
Issue 1:
-
Environment: Windows 10, Cygwin environment
-
Launch Cygwin environment
-
Execute standard Linux command to install rustup:
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s
Observed:
`default host triple: x86_64-pc-windows-msvc`
Expected:
`default host triple: x86_64-pc-windows-gnu`
Issue 2:
- Environment: Windows 10, Cygwin environment
- Launch Cygwin environment
- Execute command by passing CARGO_HOME and RUSTUP_HOME environment variables referencing full paths within Cygwin environment where rust should be installed:
CARGO_HOME="/home/user1/Rxes/rust/cargo" RUSTUP_HOME="/home/user1/Rxes/rust/env" bash -c "curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- --default-host x86_64-pc-windows-gnu"
Observed:
Instalation message contains this:
The Cargo home directory is located at:
C:/home/user1/Rxes/rust/cargo
...
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
C:/home/user1/Rxes/rust/cargo/bin
Expected:
Absolute Cygwin paths should not be "mangled" with "C:/" prefix but used as they are:
The Cargo home directory is located at:
/home/user1/Rxes/rust/cargo
...
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
/home/user1/Rxes/rust/cargo/bin
Possible Solution(s)
I think that in order to fix it, rustup installer would have to recognize/detect Cygwin/MSYS2/MinGW enviroments on Windows and handle paths and default host according to these runtimes. I think that GNU host for these environments should be default as this is primary reason why users typically set up these environments on their Windows systems.
uname -s
command returns 'CYGWIN_NT-xxxxxxxx' so the question is how Rust can extract it. If parent process of rustup-init is bash.exe, then it may be assumed, that this is running through emulated terminal on Windows. Another option would be to allow user to explicitly pass full paths on the installation script and simply trust user that what he is passing is what he really wants and simply do not change it in any way.
Notes
BTW, I was able to workaround these issues by setting these options in .bash_profile
file in my Cygwin home directory:
PATH="/sbin:/usr/sbin:.:Rxes\\rust\\cargo\\bin:${PATH}"
# I have another rustup installation on my Windows system
# which I would like to have untouched and separate from one on Cygwin.
# Removing it from it from the $PATH will hide it from rustup-init and
# makes my installation completely independent from the other one on Windows
export PATH=`echo $PATH | sed "s/:\/cygdrive\/e\/Environments\/Rust\/cargo\/bin//"`
# This weird setup of using double \\ is used intentionally in order
# to provide consistent look and feel of absolute path for rustup.
# rustup is also not able to handle absolute unix-like paths, it prepends
# them with Windows drive letter like "C:\" making them invalid. So
# relative paths here are intentional as well.
export RUSTUP_HOME="Rxes\\rust\\env"
export CARGO_HOME="Rxes\\rust\\cargo"
Basically, using relative paths would make it work.
Rustup version
rustup 1.28.2 (e4f3ad6f8 2025-04-28)
Installed toolchains
$ rustup show
Default host: x86_64-pc-windows-msvc
rustup home: C:/home/user1/Rxes/rust/env
installed toolchains
--------------------
active toolchain
----------------
no active toolchain
(Reason for this output is again the wrong mangling of the full path, `rustup` is trying to look for toolchain in `C:/home/user1/Rxes/rust/env` but tool chain was installed within Cygwin on `/home/user1/Rxes/rust/env` which is completely different directory)
By changing $PATH on the Cygwin to use relative path instead of absolute path to cargo\bin
, the output is as expected:
$ rustup show
Default host: x86_64-pc-windows-gnu
rustup home: C:\Portable\cygwin\3.6.1\home\user1\Rxes\rust\env
installed toolchains
--------------------
stable-x86_64-pc-windows-gnu (active, default)
active toolchain
----------------
name: stable-x86_64-pc-windows-gnu
active because: it's the default toolchain
installed targets:
x86_64-pc-windows-gnu
OS version
Windows 10