bazelbuild / rules_rust

Rust rules for Bazel
https://bazelbuild.github.io/rules_rust/
Apache License 2.0
656 stars 419 forks source link

Pass HOME env var when fetching version #2698

Open mvukov opened 3 months ago

mvukov commented 3 months ago

Fixes https://github.com/bazelbuild/rules_rust/issues/2662.

So, in a github action https://github.com/mvukov/rules_ros2/blob/980afb82f4af92480815e723b47a0cde4bea63a7/.github/workflows/main.yml I use my custom build image https://github.com/mvukov/bazel_builder/blob/49178bdf9c151b1fdb1fb0bac580da5d53a990fd/Dockerfile, no user defined. The github action passes user and HOME folder. The home folder seems to be /github/home and fetching the version seems to have problems with this. Therefore, I just pass the HOME env var here.

google-cla[bot] commented 3 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

mvukov commented 3 months ago

@illicitonion Can you provide some feedback on this, please?

mvukov commented 2 months ago

So, the issue seems to be the following: I build code in a container w/o user defined (hence, root). In a github action, I pass --user argument to the container. I think that cargo eventually resorts to read std::env::home that reads /etc/passwd and that fails in my case (as HOME env var is not routed). Hence, I kindly ask for this PR to be taken into consideration.

@illicitonion @UebelAndre PTAL.

mvukov commented 1 month ago

@UebelAndre That's unfortunately not going to work. I removed user from my container, so dockerfile only has root. The thing is that the github action passes user (that's how I got github action working with my container). The action also passes HOME env var which is /github/home (valid folder). Since HOME is not passed to cargo, cargo looks at /etc/passwd. However, when docker passes user via --user that user is "homeless", it doesn't exist in /etc/passwd. Therefore, we need HOME env var for cargo to work.

mvukov commented 1 month ago

@illicitonion @UebelAndre PTAL.

mvukov commented 4 weeks ago

@illicitonion @UebelAndre PTAL.

mvukov commented 1 week ago

@illicitonion @UebelAndre PTAL.