toolchain icon indicating copy to clipboard operation
toolchain copied to clipboard

Support new TOML format for rust-toolchain

Open Pytal opened this issue 3 years ago • 17 comments

Do the checklist before filing an issue:

  • [x] Is this related to the actions-rs Actions? If you think it's a problem related to Github Actions in general, use GitHub Community forum instead: https://github.community
  • [x] You've read the Contributing section about feature requests: https://github.com/actions-rs/.github/blob/master/CONTRIBUTING.md#feature-requests
  • [ ] Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome.

Motivation

As announced with Rustup 1.23.0 and documented here, there is a new TOML syntax for the rust-toolchain file which should be supported by this action.

Workflow Failure

Additionally using the TOML syntax without specifying the toolchain input will cause the workflow to fail.

Pytal avatar Nov 27 '20 20:11 Pytal

rustup is installed already on the virtual machines and upgraded by this action only if need (ex. profile input is set, but available rustup does not supports it).

In this case we should probably try to parse rust-toolchain file to see if it looks like a TOML; if it is a case, rustup needs to be upgraded first.

svartalf avatar Nov 28 '20 09:11 svartalf

Updating rustup isn't the only problem. The current ubuntu-latest version -- 20201129.1 -- already has rustup 1.23.0 (I don't know if it's at 100% deployment yet), yet I received the following error in an action run:

/usr/share/rust/.cargo/bin/rustup -V
rustup 1.23.0 (00924c9ba 2020-11-27)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.47.0-nightly (32c654a97 2020-08-19)`
Installed rustup 1.23.0 support profiles
/usr/share/rust/.cargo/bin/rustup set profile minimal
info: profile set to 'minimal'
/usr/share/rust/.cargo/bin/rustup toolchain install [toolchain]
# See https://rust-lang.github.io/rustup-components-history/ for a list of
# recently nightlies and what components are available for them.
channel = "nightly-2020-08-20"
components = ["clippy", "miri", "rustfmt"]
targets = ["thumbv7em-none-eabi",
           "riscv32imac-unknown-none-elf",
           "riscv32imc-unknown-none-elf"]
error: invalid toolchain name: '[toolchain]
# See https://rust-lang.github.io/rustup-components-history/ for a list of
# recently nightlies and what components are available for them.
channel = "nightly-2020-08-20"
components = ["clippy", "miri", "rustfmt"]
targets = ["thumbv7em-none-eabi",
           "riscv32imac-unknown-none-elf",
           "riscv32imc-unknown-none-elf"]'
Error: The process '/usr/share/rust/.cargo/bin/rustup' failed with exit code 1

The full workflow execution is at https://github.com/tock/libtock-rs/pull/263/checks?check_run_id=1484520959

EDIT: I forgot to say this, but it appears that this action is trying to pass the contents of rust-toolchain to rustup as a command line argument.

jrvanwhy avatar Dec 02 '20 06:12 jrvanwhy

rustup is installed already and upgraded by this action only if need

I'm not sure that would work on MacOS. I just found that on macos-latest a manual rustup self update fails with "error: self-update is disabled for this build of rustup".

fpoli avatar Dec 02 '20 17:12 fpoli

EDIT: I forgot to say this, but it appears that this action is trying to pass the contents of rust-toolchain to rustup as a command line argument.

Yes, I think that's the case, see https://github.com/actions-rs/toolchain/blob/553f0f7ac6080a0af3149ff4d845a47c6097ee59/src/args.ts#L28-L35 and https://github.com/actions-rs/toolchain/blob/553f0f7ac6080a0af3149ff4d845a47c6097ee59/src/args.ts#L44-L45

ebroto avatar Dec 09 '20 22:12 ebroto

Hint for people who got bitten by this: just run rustup show, you probably don't need this whole project then.

Yes, it's retarded workaround/name for a command but better than waiting eternity for someone to fix this.

Kixunil avatar Jan 14 '21 09:01 Kixunil

Your hint helped me, thanks @Kixunil. To make the hint more explicit:

If you're using a toml rust-toolchain file, you can just replace

      - name: Setup rust toolchain
        uses: actions-rs/toolchain@v1

with

      - name: Setup rust toolchain
        run: rustup show

shonfeder avatar Feb 22 '21 02:02 shonfeder

Hi there, I can easily solve this, but I'm stuck because of https://github.com/actions-rs/toolchain/issues/163 Any ehlp appreciated.

The just-run-rustup-show trick is great iff you already have rustup installed on your ci machine. Any tips for that?

JoshOrndorff avatar Mar 29 '21 14:03 JoshOrndorff

The just-run-rustup-show trick is great iff you already have rustup installed on your ci machine. Any tips for that?

If you're using shared runners, it's already there and you just run the command.

If you're using self-hosted runners, you control what's installed on the image. So refer to how GitHub sets up Rust.

crawfxrd avatar Mar 29 '21 14:03 crawfxrd

What is missing to support this? I'm willing to make the contribution, just not sure where to start

boaz-codota avatar Apr 05 '21 08:04 boaz-codota

Please merge: https://github.com/actions-rs/toolchain/pull/166

boaz-codota avatar Apr 05 '21 12:04 boaz-codota

Any chance maintainers can look at #166? Thank you!

itamarst avatar Jan 28 '22 21:01 itamarst

If anyone else is hitting this, I found that:

  • dtolnay/rust-toolchain was good but doesn't support rust-toolchain.toml files yet (mentioned in https://github.com/dtolnay/rust-toolchain/issues/29)
  • If you are using rust-toolchain.toml files, you often don't need this action at all; e.g. https://github.com/prql/prql/pull/975 removes most of ours

max-sixty avatar Sep 16 '22 23:09 max-sixty

I found that project was also nice and minimal, but didn't want to support the rust-toolchain.toml file so I created a fork of it that is specifically for this functionality for anyone else who needs it: https://github.com/dsherret/rust-toolchain-file

dsherret avatar Mar 10 '23 00:03 dsherret

Default cargo installation in GitHub Actions already honors toolchain file, you don't even need an action to install anything, it "just works" automatically and will download toolchains and specified components if they are not yet available.

Simply remove actions-rs/toolchain from your workflow, it is no longer necessary.

nazar-pc avatar Mar 10 '23 00:03 nazar-pc

@nazar-pc you're right! I just tested it out switching between versions and it seems to work. I wish I had known that earlier. Thanks!

Edit: Huh, one drawback is it doesn't do other setup stuff like setup colours and enable the new sparse registry protocol like what dtolnay/rust-toolchain does. All the output is white text. I'm going to keep using the fork for the time being and just slim it down to skip the rustup steps.

image

dsherret avatar Mar 10 '23 01:03 dsherret

For colors you need to set CARGO_TERM_COLOR: always in environment variables, same for other features.

nazar-pc avatar Mar 10 '23 01:03 nazar-pc

@nazar-pc yeah, but it's more verbose compared to a single line and doing this helps keep multiple repos in sync. I like the defaults dtolnay/rust-toolchain does and it helps me not have to worry about handling differences in those defaults when upgrading versions.

dsherret avatar Mar 10 '23 02:03 dsherret