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

[Bug]: py_binary breaks cross_platform build when building image with rules_oci #218

Closed
lyao-77 opened this issue Nov 7, 2023 · 2 comments · Fixed by #233
Closed

[Bug]: py_binary breaks cross_platform build when building image with rules_oci #218

lyao-77 opened this issue Nov 7, 2023 · 2 comments · Fixed by #233
Assignees
Labels
bug Something isn't working

Comments

@lyao-77
Copy link

lyao-77 commented Nov 7, 2023

What happened?

When we use py_binary to build docker images with rules_oci, we couldn't build the tarball for ubuntu images. The error log:

ERROR: /Users/lyao/bazel/bazel-examples/oci_python_image/hello_world/BUILD.bazel:18:10: Creating virtual environment for //hello_world:hello_world failed: (Exit 126): sandbox-exec failed: error executing command
(cd /private/var/tmp/_bazel_lyao/1e813cdbb954646ce252ec3692bb82d4/sandbox/darwin-sandbox/10/execroot/_main &&
exec env -
TMPDIR=/var/folders/gm/r7n8598x7zq6rwkd1_r75_3h0000gp/T/
/usr/bin/sandbox-exec -f /private/var/tmp/_bazel_lyao/1e813cdbb954646ce252ec3692bb82d4/sandbox/darwin-sandbox/10/sandbox.sb /var/tmp/_bazel_lyao/install/7d4a2659eff664c24e2f7d717eef5139/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_lyao/1e813cdbb954646ce252ec3692bb82d4/sandbox/darwin-sandbox/10/stats.out' /bin/bash -c bazel-out/darwin_arm64-fastbuild-ST-baeacbe55d95/bin/hello_world/hello_world.venv_venv.sh)
bazel-out/darwin_arm64-fastbuild-ST-baeacbe55d95/bin/hello_world/hello_world.venv_venv.sh: line 38: external/rules_python0.21.0python~python3_9_aarch64-unknown-linux-gnu/bin/python3: cannot execute binary file
INFO: Elapsed time: 0.763s, Critical Path: 0.37s
INFO: 3 processes: 3 internal.
FAILED: Build did NOT complete successfully

I'm using https://github.com/aspect-build/bazel-examples/tree/main/oci_python_image to reproduce the error.

The issue seems relate to the wrong python interpreter path and is not platform agnostic when calling venv.

I tried the following command with Mac as a workaround:
❯ bazel build //... --sandbox_debug --platform=//hello_world:x86_64_linux
it ran into the same issue (different error) and seems the current implementation of py_binary breaks the cross-platform build.

Version

Development (host) and target OS/architectures:
host: Mac with M1
target OS/arch: linux

Output of bazel --version:
bazel 6.2.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
the same as the example: https://github.com/aspect-build/bazel-examples

Language(s) and/or frameworks involved:

How to reproduce

build the example "oci_python_image" with Mac

Any other information?

No response

@lyao-77 lyao-77 added the bug Something isn't working label Nov 7, 2023
@github-actions github-actions bot added the untriaged Requires traige label Nov 7, 2023
@euan-cowie
Copy link

I'm having the exact same issue. Did you manage to solve or find a workaround? Will let you know if I do.

@mattem
Copy link
Collaborator

mattem commented Jan 2, 2024

Will be resolved by #233

@mattem mattem removed the untriaged Requires traige label Jan 2, 2024
@mattem mattem self-assigned this Jan 2, 2024
@mattem mattem closed this as completed in ebabbaf Feb 15, 2024
@github-project-automation github-project-automation bot moved this to ✅ Done in Open Source Feb 15, 2024
alexeagle added a commit that referenced this issue Feb 21, 2024
### Type of change

- Refactor (a code change that neither fixes a bug or adds a new
feature)


### Test plan

- Covered by existing test cases

#233 was mentioned as a fix for #218 but #233 includes a dependency on
openssl. This dependency on openssl makes building containers on MacOS
difficult as we then need to cross build openssl. I see that there was
an attempt to remove the openssl dependency `rattler_installs_packages`
however, `native-tls` is in the default features and is the only default
feature. Disabling `default-features` removes the dependency on openssl.

---------

Co-authored-by: Alex Eagle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants