My workflow is something like this:
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all --tests -- -D warnings
This workflow works great on GH actions, but run with act, I get errors. Mainly:
[Build/Build] ❓ ::add-matcher::/actions/actions-rs-cargo@v1/dist/.matchers/rust.json
[Build/Build] ❗ ::error::cargo is not installed by default for some virtual environments, see https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions
[Build/Build] ❗ ::error::To install it, use this action: https://github.com/actions-rs/toolchain
[Build/Build] ❗ ::error::Unable to locate executable file: cargo. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
[Build/Build] ❌ Failure - Cargo clippy
Same. I get | /github/workflow/1: line 2: cargo: command not found with just the basic Rust workflow (without using the actions-rs action).
This is the file:
name: Rust
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --verbose
EDIT: I saw that this is a "pinned issue". (Didn't know this existed) Which explains what I see.
Solution: Provide the correct runner image. Either provide -P ... on the command line, or provide it in the .actrc file:
.actrc:
-P ubuntu-latest=act-environments-ubuntu:18.04
Tested with:
cargo build command I posted above.action-rs action.For just cargo build the rust:latest image works. But the action-rs also needs node support. I decided to trade simplicity (using nektos' image) for disk space.
@siedentop should that be:
-P ubuntu-latest=nektos/act-environments-ubuntu:18.04
I have the same problem. Using -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 didn't help in my case. And it shouldn't be needed, as I use actions-rs/toolchain@v1 to install rustup and cargo manually, just like @vmalloc does.
What confuses me is that rustup show active-toolchain, rustup which cargo, which cargo and cargo -v all work correctly, so I wonder why actions-rs/clippy-check@v1 doesn't find cargo. Internally, actions-rs/clippy-check@v1 uses which cargo to check for the presence of cargo (see https://github.com/actions-rs/core/blob/1b3bf36903648e0f2db0286ede1348abbac16f60/src/commands/cargo.ts#L31), so it's strange that it doesn't work.
Issue is stale and will be closed in 7 days unless there is new activity
This issue persists to this day, making act unusable for many rust projects, and thus shouldn't be closed, I think.
If I put this in my .actrc:
-P ubuntu-latest=nektos/act-environments-ubuntu:18.04
Then run act:
❯ act
[CI/Check-1] 🧪 Matrix: map[rust:stable]
[CI/Check-2] 🧪 Matrix: map[rust:1.31.0]
[CI/Check-1] 🚀 Start image=nektos/act-environments-ubuntu:18.04
[CI/Check-2] 🚀 Start image=nektos/act-environments-ubuntu:18.04
My computer fans spin up like crazy. Worse than compiling a large crate. And it doesn't progress any further than Start image=...
Issue is stale and will be closed in 7 days unless there is new activity
Most helpful comment
I have the same problem. Using
-P ubuntu-latest=nektos/act-environments-ubuntu:18.04didn't help in my case. And it shouldn't be needed, as I useactions-rs/toolchain@v1to install rustup and cargo manually, just like @vmalloc does.What confuses me is that
rustup show active-toolchain,rustup which cargo,which cargoandcargo -vall work correctly, so I wonder whyactions-rs/clippy-check@v1doesn't find cargo. Internally,actions-rs/clippy-check@v1useswhich cargoto check for the presence of cargo (see https://github.com/actions-rs/core/blob/1b3bf36903648e0f2db0286ede1348abbac16f60/src/commands/cargo.ts#L31), so it's strange that it doesn't work.