moonrepo / setup-rust

A maintained GitHub action for setting up Rust and Cargo.
84 stars 6 forks source link

allow building with `--locked` #20

Open jtmoon79 opened 1 month ago

jtmoon79 commented 1 month ago

tl;dr I would like to build bins with option --locked

From this failed build I got error

Run moonrepo/setup-rust@v1
  with:
    channel: 1.70.0
    bins: cross
    targets: aarch64-apple-ios
    cache: true
    cache-target: debug
    inherit-toolchain: false
    target-dirs: target

...

  WARN The package cargo-cache v0.8.3 will be installed from source (with cargo)
 WARN The package cross v0.2.5 will be installed from source (with cargo)

...

   Compiling cfg-if v1.0.0
error: failed to compile `cargo-cache v0.8.3`, intermediate artifacts can be found at `/var/folders/w3/xh1ngrc13bg46kmhfdprbpyw0000gn/T/cargo-installgoVcWl`

Caused by:
  package `cargo-platform v0.1.8` cannot be built because it requires rustc 1.73 or newer, while the currently active rustc version is 1.70.0
  Try re-running cargo install with `--locked`

From this rust.yml code

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1
  MSRV_UPLOAD: "1.70.0"
jobs:
  job_cross_targets_macos:
    name: cross ${{ matrix.target }} on macos-13
    strategy:
      matrix:
        target:
          - x86_64-apple-darwin
          - aarch64-apple-darwin
          - aarch64-apple-ios
          - x86_64-apple-ios
    runs-on: macos-13
    steps:
      - uses: actions/checkout@v4
      - uses: moonrepo/setup-rust@v1
        with:
          channel: ${{ env.MSRV_UPLOAD }}
          bins: cross
          targets: ${{ matrix.target }}
      - run: |
          set -eux
          uname -a
          rustup show
          cross --version
          cross check --lib --bins --target ${{ matrix.target }}

The built-in advice from the error message above is pass CLI argument --locked.

Try re-running cargo install with --locked

Can you allow passing --locked to the cargo install command invoked by the with statement?

milesj commented 1 month ago

@jtmoon79 I'm not entirely sure --locked would solve the problem of the wrong Rust version being used? Can you confirm if it does?