Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "cargo is not installed by default for some virtual environments", while using the correct toolchain action #297

Closed
vmalloc opened this issue Jun 29, 2020 · 11 comments
Labels
area/runner Relating to errors in the runner stale

Comments

@vmalloc
Copy link

vmalloc commented Jun 29, 2020

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
@cplee cplee added the area/runner Relating to errors in the runner label Jul 13, 2020
@siedentop
Copy link

siedentop commented 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.

@siedentop
Copy link

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.

@stackedsax
Copy link

@siedentop should that be:

-P ubuntu-latest=nektos/act-environments-ubuntu:18.04

@tmcguire
Copy link

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.

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the stale label Oct 12, 2020
@regexident
Copy link

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

@mandrean
Copy link

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

@cplee cplee removed the stale label Oct 12, 2020
@github-actions
Copy link
Contributor

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

@Skallwar
Copy link

Skallwar commented Jul 7, 2021

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

It does for me, I waited around 10 minutes

@fadeevab
Copy link

fadeevab commented 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.

@injectedfusion
Copy link

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runner Relating to errors in the runner stale
Projects
None yet
Development

No branches or pull requests

10 participants