[GH-ISSUE #297] Getting "cargo is not installed by default for some virtual environments", while using the correct toolchain action #209

Closed
opened 2026-03-01 21:41:16 +03:00 by kerem · 11 comments
Owner

Originally created by @vmalloc on GitHub (Jun 29, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/297

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
Originally created by @vmalloc on GitHub (Jun 29, 2020). Original GitHub issue: https://github.com/nektos/act/issues/297 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 ```
kerem 2026-03-01 21:41:16 +03:00
Author
Owner

@siedentop commented on GitHub (Jul 22, 2020):

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.

<!-- gh-comment-id:662590584 --> @siedentop commented on GitHub (Jul 22, 2020): 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: ```yaml 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](https://github.com/nektos/act/issues/107) is a "pinned issue". (Didn't know this existed) Which explains what I see.
Author
Owner

@siedentop commented on GitHub (Jul 23, 2020):

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:

  • the plain cargo build command I posted above.
  • the 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.

<!-- gh-comment-id:662765430 --> @siedentop commented on GitHub (Jul 23, 2020): **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: * the plain `cargo build` command I posted above. * the `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.
Author
Owner

@stackedsax commented on GitHub (Jul 31, 2020):

@siedentop should that be:

-P ubuntu-latest=nektos/act-environments-ubuntu:18.04
<!-- gh-comment-id:667345683 --> @stackedsax commented on GitHub (Jul 31, 2020): @siedentop should that be: ``` -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 ```
Author
Owner

@tmcguire commented on GitHub (Aug 12, 2020):

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 github.com/actions-rs/core@1b3bf36903/src/commands/cargo.ts (L31)), so it's strange that it doesn't work.

<!-- gh-comment-id:672745151 --> @tmcguire commented on GitHub (Aug 12, 2020): 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.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 12, 2020):

Issue is stale and will be closed in 7 days unless there is new activity

<!-- gh-comment-id:706794702 --> @github-actions[bot] commented on GitHub (Oct 12, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@regexident commented on GitHub (Oct 12, 2020):

This issue persists to this day, making act unusable for many rust projects, and thus shouldn't be closed, I think.

<!-- gh-comment-id:707034643 --> @regexident commented on GitHub (Oct 12, 2020): This issue persists to this day, making **act** unusable for many rust projects, and thus shouldn't be closed, I think.
Author
Owner

@mandrean commented on GitHub (Oct 12, 2020):

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=...

<!-- gh-comment-id:707105833 --> @mandrean commented on GitHub (Oct 12, 2020): 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=...`
Author
Owner

@github-actions[bot] commented on GitHub (Dec 12, 2020):

Issue is stale and will be closed in 7 days unless there is new activity

<!-- gh-comment-id:743504792 --> @github-actions[bot] commented on GitHub (Dec 12, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@Skallwar commented on GitHub (Jul 7, 2021):

And it doesn't progress any further than Start image=...

It does for me, I waited around 10 minutes

<!-- gh-comment-id:875501849 --> @Skallwar commented on GitHub (Jul 7, 2021): > And it doesn't progress any further than Start image=... It does for me, I waited around 10 minutes
Author
Owner

@fadeevab commented on GitHub (Jan 5, 2022):

This works for me:
act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-latest
Wait until it silently downloads the docker image.

<!-- gh-comment-id:1006137763 --> @fadeevab commented on GitHub (Jan 5, 2022): This works for me: `act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-latest` Wait until it silently downloads the docker image.
Author
Owner

@injectedfusion commented on GitHub (Nov 29, 2022):

This works for me: act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-latest Wait until it silently downloads the docker image.

Thank you for this. This worked for me.

<!-- gh-comment-id:1331026388 --> @injectedfusion commented on GitHub (Nov 29, 2022): > This works for me: `act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-latest` Wait until it silently downloads the docker image. Thank you for this. This worked for me.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#209
No description provided.