moonrepo / setup-rust

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

Fails to cache on macos-13 #18

Closed flaviojs closed 2 months ago

flaviojs commented 2 months ago

The post step of this github action fails on macos-13 with:

Error: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.

No idea what command line is being tried, it is printed in the other 2 successful cases but not in this case.

Workflow (clipped):

# ...
jobs:
  build-linux:
    name: Linux
    runs-on: ubuntu-latest
    steps:
    # ...
    - name: Install dependencies (rust)
      uses: moonrepo/setup-rust@v1
      with:
        targets: x86_64-unknown-linux-gnu
        components: clippy,rustfmt
    # ...

  build-macos:
    name: MacOS
    runs-on: macos-13 # macos-latest/macos-14 has an ARM cpu (Apple M1) but we want an AMD64 cpu
    steps:
    # ...
    - name: Install dependencies (rust)
      uses: moonrepo/setup-rust@v1
      with:
        targets: x86_64-apple-darwin
        components: clippy,rustfmt
    # ...

  build-cygwin:
    name: Cygwin
    runs-on: windows-latest
    steps:
    # ...
    - name: Install dependencies (rust)
      uses: moonrepo/setup-rust@v1
      with:
        targets: x86_64-pc-windows-gnu
        components: clippy,rustfmt
    # ...
flaviojs commented 2 months ago

The successful cases have a tar command line where this one fails. The macos-13 runner has tar available with version:

bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8

milesj commented 2 months ago

If you run it in GHA with debug mode on, do the logs reveal anything?

flaviojs commented 2 months ago

Nope, I got the same information. Probably this action and its dependencies do not log/trace the path(s) before the error is triggered.

flaviojs commented 2 months ago

I got a list of all the files in the runner and the two paths that can be cached do not exist. Doing mkdir ~/.cargo/registry silences the error, so at least one cache path needs to exist to avoid the error.

I'm at the start of a conversion from C to rust. The crate does not exist in the repo yet, so ~/.cargo/registry is only created when needed? The crate will not be in the repo root, so (github_workspace)/target/debug will not exist. A way to set the crate/workspace dir (or dirs) would be helpful for non-root use cases, but that is out of scope for this issue.

milesj commented 2 months ago

This should maybe do it: https://github.com/moonrepo/setup-rust/pull/19

I'm not 100% sure how GH handles loading cache with paths that were skipped.

milesj commented 2 months ago

Ok I tagged those changes, retry the pipeline and see if it works.

flaviojs commented 2 months ago

It works, thanks. :+1:

milesj commented 2 months ago

Sweet, thanks for reporting.