Skip to content

Incorrect toolchain check when running cross with active or default toolchain #1678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 of 11 tasks
Rileran opened this issue May 7, 2025 · 9 comments · Fixed by #1681 or #1683
Closed
3 of 11 tasks

Incorrect toolchain check when running cross with active or default toolchain #1678

Rileran opened this issue May 7, 2025 · 9 comments · Fixed by #1681 or #1683

Comments

@Rileran
Copy link

Rileran commented May 7, 2025

Checklist

Describe your issue

When running any cross command, cross tries to download the stable version while it is already installed.

This is because when running rustup toolchain list, my toolchain stable has a suffix (active, default), which makes the check fail. I believe adding the --quiet flag at the end of the command should fix the issue.

I have tried both the latest stable 0.2.5 version and the lastet version on the main branch (9e2298e at the time of writing)

Two months ago, on a version not released yet, the command rustup toolchain list was replaced with rustup --quiet toolchain list. This however does not fix the issue as the --quiet flag applies to the rustup command and not the list command.

What target(s) are you cross-compiling for?

No response

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5

Example

$ cross --help -v
+ cargo metadata --format-version 1
+ rustc --print sysroot
+ rustup toolchain list
+ rustup --verbose toolchain add stable-x86_64-unknown-linux-gnu --profile minimal
debug: read metadata version: '12'
debug: updating existing install for 'stable-x86_64-unknown-linux-gnu'
debug: toolchain directory: '/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
debug: creating temp file: /home/user/.rustup/tmp/yivvct2ihzgg02o9_file
debug: downloading file from: 'https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256'
debug: downloading with reqwest
debug: deleted temp file: /home/user/.rustup/tmp/yivvct2ihzgg02o9_file
debug: toolchain is already up to date

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.86.0 (05f9846f8 2025-03-31)

info: checking for self-update
+ rustup target list --toolchain stable-x86_64-unknown-linux-gnu
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
[cross] note: Falling back to `cargo` on the host.
+ cargo --help -v
Rust's package manager

Usage: cargo [+toolchain] [OPTIONS] [COMMAND]
       cargo [+toolchain] [OPTIONS] -Zscript <MANIFEST_RS> [ARGS]...
...

Example of rustup toolchain list result

$ rustup toolchain list
stable-x86_64-unknown-linux-gnu (active, default)
nightly-x86_64-unknown-linux-gnu

Additional information / notes

No response

@Emilgardis
Copy link
Member

Thats strange, i was sure this fixed the issue, will have a look again

reneleonhardt added a commit to reneleonhardt/rust-cross that referenced this issue May 21, 2025
reneleonhardt added a commit to reneleonhardt/rust-cross that referenced this issue May 21, 2025
@reneleonhardt
Copy link
Contributor

@Rileran can you try #1681 to see if it fixes your problem?

reneleonhardt added a commit to reneleonhardt/rust-cross that referenced this issue May 21, 2025
@Rileran
Copy link
Author

Rileran commented May 21, 2025

@reneleonhardt This fix works for me, thanks!

github-merge-queue bot pushed a commit that referenced this issue May 21, 2025
Fixes #1678

### Old
```shell
$ rustup --quiet toolchain list
stable-aarch64-apple-darwin (active, default)
```

### New
```shell
$ rustup toolchain list --quiet
stable-aarch64-apple-darwin
```
@wcampbell0x2a
Copy link

Hey! I'm seeing issues that may be related to this fix? I build cargo-cross from git.

https://github.com/wcampbell0x2a/backhand/actions/runs/15177787965/job/42681187474

Error: 
   0: `rustup toolchain list --quiet` failed with exit status: 1

Location:
   src/errors.rs:147

Stdout:
   error: unexpected argument '--quiet' found

   Usage: rustup toolchain list [OPTIONS]

   For more information, try '--help'.

@reneleonhardt
Copy link
Contributor

Thank you for the report!
Could you please add new commands before the failing one and rebuild it?

https://github.com/rust-lang/rustup/tags

rustup --version # rustup 1.28.2 (2025-04-28)
rustup toolchain list --help
rustup self update

1.28.0 added --quiet
https://github.com/rust-lang/rustup/blob/master/CHANGELOG.md#1280---2025-03-04

@ueda-soma
Copy link

ueda-soma commented May 23, 2025

Hi,

I also encountered an error with rustup v1.26.0 (ubuntu noble 1.26.0-5build1).
FYI: Rustup is installed with APT.

$ cross build --release --target aarch64-unknown-linux-musl
Error: 
   0: `rustup toolchain list --quiet` failed with exit status: 1

Location:
   src/errors.rs:147

Stdout:
   error: Found argument '--quiet' which wasn't expected, or isn't valid in this context

        If you tried to supply `--quiet` as a value rather than a flag, use `-- --quiet`

   USAGE:
       rustup toolchain list [OPTIONS]

   For more information try --help
$ rustup --version
rustup 1.26.0 (2024-04-01)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.87.0 (17067e9ac 2025-05-09)`
$ rustup self update
error: self-update is disabled for this build of rustup
error: you should probably use your system package manager to update rustup

Of course, this error should be fixed after installing rustup by non-APT methods.

reneleonhardt added a commit to reneleonhardt/rust-cross that referenced this issue May 23, 2025
reneleonhardt added a commit to reneleonhardt/rust-cross that referenced this issue May 23, 2025
reneleonhardt added a commit to reneleonhardt/rust-cross that referenced this issue May 23, 2025
@reneleonhardt
Copy link
Contributor

reneleonhardt commented May 23, 2025

Thanks! rustup will only be available from Debian 13 onwards... but also only an outdated version like Ubuntu 24.04 provides 😞
https://packages.debian.org/search?keywords=rustup

Thank you for your report, I prepared another fix for legacy rustup versions.
#1683

Interestingly enough, rustup self update has not only been disabled for package managers, but also in CI runs since 1.28.0. So there's no easy way anymore to self-heal in such cases.
rust-lang/rustup#3907

Despite installing rustup in the official way yourself of course... 😄
https://www.rust-lang.org/tools/install

reneleonhardt added a commit to reneleonhardt/rust-cross that referenced this issue May 23, 2025
reneleonhardt added a commit to reneleonhardt/rust-cross that referenced this issue May 23, 2025
reneleonhardt added a commit to reneleonhardt/rust-cross that referenced this issue May 23, 2025
github-merge-queue bot pushed a commit that referenced this issue May 24, 2025
Fixes #1678

Unfortunately some installations use legacy versions, my previous fix
was only working for the current rustup >= 1.28.0.
@reneleonhardt
Copy link
Contributor

@wcampbell0x2a @ueda-soma my "backport" of --quiet has been merged if you want to try cross main again with legacy rustup versions 😅

@ueda-soma
Copy link

ueda-soma commented May 26, 2025

@reneleonhardt Thanks, it seems to work with 51f46f2!

$ cargo install cross --git https://github.com/cross-rs/cross
  Installing cross v0.2.5 (https://github.com/cross-rs/cross#51f46f29)
$ cross build --release --target aarch64-unknown-linux-gnu
    Finished `release` profile [optimized] target(s) in 41.39s
$ cross --version
cross 0.2.5 (51f46f2 2025-05-24)
$ rustup --version
rustup 1.26.0 (2024-04-01)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants