BlackDex / rust-musl

For compiling static Rust binaries using musl toolchain with some pre-compiled static libraries
Apache License 2.0
33 stars 4 forks source link

No cargo version configured #11

Closed Ludea closed 3 days ago

Ludea commented 5 days ago

Hi,

I get

error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured.
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.

when using container with GHA:

jobs:
  build_container:
    runs-on: ubuntu-latest
    container: blackdex/rust-musl:aarch64-musl-stable-1.82.0
    steps:
      - uses: actions/checkout@v4
      - name: Build
        run: cargo build --release
BlackDex commented 5 days ago

Strange, as you can see i kinda do the same during the test builds https://github.com/BlackDex/rust-musl/actions/runs/11477497940/job/31939721088#step:14:9

Though that uses the docker run and not my image as GHA image. I actually have never tried that, but in theory it should work.

Maybe something in your checkout is overwriting something? Ill have to test this my self to see what happens.

Is the repo/branch you use for this public?

Ludea commented 5 days ago

https://github.com/Ludea/lucle/actions/runs/11540151227/job/32120633661

Yaml file: https://github.com/Ludea/lucle/blob/main/.github/workflows/build_container.yaml

BlackDex commented 5 days ago

Strange, when i try to use act, it seems to work just fine.

act push -j build_container

I suspect it has something to do with some default env's Github sets. Ill check a bit further.

BlackDex commented 5 days ago

You can probably fix this for now by setting:

env:
  HOME: /root
Ludea commented 5 days ago
env:
  HOME: /root

Fix my issue, thanks

BlackDex commented 5 days ago

Ok, cool I'm working on a fix for this so that the next build's will be supported this way.

BlackDex commented 5 days ago

@Ludea, you should now be able to remove that env again. I fixed the images.

Ludea commented 5 days ago

Now I get /__w/_temp/b84a7ab6-8893-49f7-8d31-b598ae0128ba.sh: 1: cargo: not found Error: Process completed with exit code 127 without env

Ludea commented 4 days ago

I try with ghcr.io/blackdex/rust-musl:aarch64-musl-nightly-2024-10-25, and it works as expected (like your test) (with env var)

I still get

error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured.
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.

without env var

With ghcr.io/blackdex/rust-musl:aarch64-musl I get /__w/_temp/b84a7ab6-8893-49f7-8d31-b598ae0128ba.sh: 1: cargo: not found Error: Process completed with exit code 127 without env var

BlackDex commented 4 days ago

Yea i noticed. GitHub Actions is doing something strange.

BlackDex commented 4 days ago

@Ludea Ok, i think i know what i have to do to get this working. I only need to check if this will not cause any issues with at least Vaultwarden for example. And I'm not sure if it could effect others, but i do not think it will.

I need to install/define cargo/rustup at a different location and define the right env variables for this. The official rust images work like this, and that will probably help make it more compatible and maybe also to be more compatible with cross-rs even.

BlackDex commented 3 days ago

I have it working now, and i tested it using a fork of your project. The images are currently being built and once done it should be able to run without any extra env needed to be set.

Fixed via 8831be56e896d22aea117ec2cb8d6051a7fef46b