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

Python example tries to run as bash script on macOS #186

Closed
YorikSar opened this issue Feb 17, 2022 · 0 comments · Fixed by #189
Closed

Python example tries to run as bash script on macOS #186

YorikSar opened this issue Feb 17, 2022 · 0 comments · Fixed by #189
Assignees

Comments

@YorikSar
Copy link
Member

Describe the bug
When I run python example, it gets executed as shell script instead of Python with errors like:

...
from: can't read /var/mail/__future__
/private/var/tmp/_bazel_tweag/6888388f61d1891f87da729e10be1777/execroot/__main__/bazel-out/darwin-fastbuild/bin/hello: line 13: import: command not found
/private/var/tmp/_bazel_tweag/6888388f61d1891f87da729e10be1777/execroot/__main__/bazel-out/darwin-fastbuild/bin/hello: line 19: del: command not found
...

To Reproduce

cd examples/toolchains/python
nix-shell --command "bazel run --config=nix :hello"

Expected behavior
"Hello, world!" line should be written to the output.

Environment

  • OS name + version: macOS Monterey 12.2.1 (also reproducible on CI with macos-11 builder
  • Version of the code: Got this issue while trying to make examples work on macOS on this commit

Additional context
macOS doesn't support calling scripts with scripts in shebang (see StackOverflow thread for example), but python toolchain by default sets shebang as direct path to python executable taken from the system. In nixpkgs, that executable is a shell wrapper around python itself, so it doesn't work on macOS. It was fixed in NixOS/nixpkgs#93757 for scripts generated by nixpkgs, but this wrapper is generated by Bazel from this template. We already override it for Bazel 4.2.0+ here, so we should provide full path to Bash before path to Python there.

@YorikSar YorikSar self-assigned this Feb 17, 2022
@YorikSar YorikSar changed the title Bad shebang for py_binary on macOS Python example tries to run as bash script on macOS Feb 17, 2022
YorikSar added a commit that referenced this issue Feb 17, 2022
All examples are already using 21.11 nixpkgs, so that shouldn't prevent
them from working on Big Sur.

Python example is broken because of #186 and Rust one because of #187,
so skip them for now.

Fixes #176
YorikSar added a commit that referenced this issue Feb 17, 2022
All examples are already using 21.11 nixpkgs, so that shouldn't prevent
them from working on Big Sur.

Python example is broken because of #186 and Rust one because of #187,
so skip them for now.

Fixes #176
YorikSar added a commit that referenced this issue Feb 21, 2022
All examples are already using 21.11 nixpkgs, so that shouldn't prevent
them from working on Big Sur.

Python example is broken because of #186 and Rust one because of #187,
so skip them for now.

Fixes #176
YorikSar added a commit that referenced this issue Feb 21, 2022
YorikSar added a commit that referenced this issue Feb 21, 2022
YorikSar added a commit that referenced this issue Feb 21, 2022
Leverage makeScriptWriter from nixpkgs that includes fix
NixOS/nixpkgs#93757 for macOS compatibility.

Fixes #186
@mergify mergify bot closed this as completed in #189 Feb 21, 2022
ryanbujnowicz pushed a commit to ryanbujnowicz/rules_nixpkgs that referenced this issue Mar 5, 2022
All examples are already using 21.11 nixpkgs, so that shouldn't prevent
them from working on Big Sur.

Python example is broken because of tweag#186 and Rust one because of tweag#187,
so skip them for now.

Fixes tweag#176
ryanbujnowicz pushed a commit to ryanbujnowicz/rules_nixpkgs that referenced this issue Mar 5, 2022
Leverage makeScriptWriter from nixpkgs that includes fix
NixOS/nixpkgs#93757 for macOS compatibility.

Fixes tweag#186
fricklerhandwerk pushed a commit that referenced this issue Mar 7, 2022
Leverage makeScriptWriter from nixpkgs that includes fix
NixOS/nixpkgs#93757 for macOS compatibility.

Fixes #186
fricklerhandwerk pushed a commit that referenced this issue Mar 8, 2022
Leverage makeScriptWriter from nixpkgs that includes fix
NixOS/nixpkgs#93757 for macOS compatibility.

Fixes #186
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant