cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.8k stars 379 forks source link

`cargo: not found` when using `cross` in GitHub Actions #1528

Closed sundaram123krishnan closed 4 months ago

sundaram123krishnan commented 4 months ago

I am encountering an issue when using cross in my GitHub Actions workflow. The error message indicates that cargo is not found.

This occurs during the build step in my CI pipeline. Below is the relevant portion of my GitHub Actions configuration:

jobs: 
  test:
    name: test
    runs-on: ubuntu-latest
    strategy: 
      matrix:
        target: [ aarch64-unknown-linux-gnu ]
    steps:
      - name: Checkout
        uses: actions/checkout@v1
      - name: Install rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          override: true
          target: ${{ matrix.target }}

      - name: Build target
        uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: build
          args: --bin piggui --release --features "gui","pi_hw" --target ${{ matrix.target }}

The build fails with the error:

sh: 1: cargo: not found

But when i try to list cargo packages:

ls /root/.cargo/bin

cross is present.

What is the cause of this strange behavior? Any help is much appreciated! Thx in advance!

Emilgardis commented 4 months ago

Do you have a link to the logs? This shouldn't happen, but it could be due to actions-rs and it not being maintained.

sundaram123krishnan commented 4 months ago

So, it perfectly builds when pushed to Github workflow. I am using act to build and test locally. Maybe that is responsible for this?

Emilgardis commented 4 months ago

aha, yes act is not working properly on 0.2.5, see https://github.com/cross-rs/cross/issues/1321

you'll need a version which includes #1485, install cross before actions-rs installs it with run: cargo install cross --git https://github.com/cross-rs/cross

also, as I said, don't use actions-rs, it's unmaintained

sundaram123krishnan commented 4 months ago

Thx for the mention