houseabsolute / actions-rust-cross

GitHub Action to compile Rust with cross
Apache License 2.0
121 stars 13 forks source link

Action overwrites `GITHUB_PATH`, making other installed tools unaccessible #1

Closed devpikachu closed 1 year ago

devpikachu commented 1 year ago

Trying to use this action in my pipeline, and currently, the action overwrites GITHUB_PATH, thus making other installed tools unusable, such as protoc in my case.

 thread 'main' panicked at 'Could not find `protoc` installation and this build crate cannot proceed without
      this knowledge. If `protoc` is installed and this crate had trouble finding
      it, you can set the `PROTOC` environment variable with the specific path to your
      installed `protoc` binary.If you're on debian, try `apt-get install protobuf-compiler` or download it from https://github.com/protocolbuffers/protobuf/releases

https://github.com/houseabsolute/actions-rust-cross/blob/9a602122c2f4df61140216897231df93c0922a22/action.yml#LL29C12-L29C60

autarch commented 1 year ago

Ah, I just saw this issue. This should be a simple fix.

autarch commented 1 year ago

Actually, I'm a bit confused as to how this is happening. From reading the GH Actions docs it seems like appending to $GITHUB_PATH should just add a directory, not wipe out any that already exist. Can you point me to workflow you're using that's having this issue?

devpikachu commented 1 year ago

Hey @autarch ! Thanks for replying. Of course, see below:

autarch commented 1 year ago

I wrote some tests to check for this. AFAICT it's not overwriting the $PATH. See https://github.com/houseabsolute/actions-rust-cross/actions/runs/4399492494/jobs/7704067598#step:7:10

autarch commented 1 year ago

Oh wait, I see what's happening. The problem is that builds for non-native architectures are run inside a Docker container. That container doesn't have protoc in it.

There's a number of ways to solve this but I think the simplest is to add pre-build hooks for cross that install protoc -https://github.com/cross-rs/cross#pre-build-hook

You might find my ubi project handy for this.

autarch commented 1 year ago

I'm going to close this since it's not a bug with the action. But on the plus side, it got me to write some tests for it, which is great!

autarch commented 1 year ago

I just realized ubi won't work with the protobuf project, since it ships more than just a binary in its releases.

devpikachu commented 1 year ago

@autarch Thank you so much for looking into this and for providing this very valuable insight. It makes perfect sense why it doesn't work and it totally slipped my mind checking for the fact that it runs inside a docker container.

I will go about adding pre-build hooks as linked above.