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

always set 'use_default_shell_env' in ctx.actions.run #215

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

malt3
Copy link

@malt3 malt3 commented Jun 4, 2024

Aspect uses shell wrappers that invoke tools like dirname and uname. When the default shell env is not inherited, this prevents tools from being found on systems without a working fallback $PATH (like NixOS).

This might be incompatible with setting the env attribute, unless the bazel flag --incompatible_merge_fixed_and_default_shell_env is set on Bazel versions < 7.

See also: NixOS/nixpkgs#289505


Changes are visible to end-users: no

Test plan

  • Covered by existing test cases

Aspect uses shell wrappers that invoke tools like `dirname` and `uname`.
When the default shell env is not inherited, this prevents tools from
being found on systems without a working fallback $PATH (like NixOS).

See also: NixOS/nixpkgs#289505
@Strum355
Copy link
Contributor

Strum355 commented Jun 4, 2024

Im surprised I havent had this issue (running on NixOS), I wonder am I not hitting these codepaths 🤔 we set PATH with --action_env

@malt3 malt3 closed this Jun 4, 2024
@malt3 malt3 reopened this Jun 4, 2024
@malt3
Copy link
Author

malt3 commented Jun 5, 2024

@Strum355 that is surprising. I created a reproducer in this branch:

https://github.com/tweag/nix_bazel_codelab/tree/malt3-esbuild-reproducer

Could you try the following instructions on NixOS?

  • check out the repository and branch
  • enter the dev shell with direnv (or install bazel_7 from nixpkgs)
  • run bazel build //typescript:bundle

You should see this:

bazel build //typescript:bundle
/nix/store/3m6f30w7f6whxm6zl1m6nfr8q24p27lp-bazel-nodejs-toolchain
INFO: Analyzed target //typescript:bundle (170 packages loaded, 3100 targets configured).
ERROR: /home/malte/github.com/tweag/nix_bazel_codelab/typescript/BUILD.bazel:30:8: Bundling Javascript typescript/app.js [esbuild] failed: (Exit 127): launcher.sh failed: error executing esbuild command (from target //typescript:bundle) bazel-out/k8-opt-exec-ST-4e761c9674ba/bin/external/aspect_rules_esbuild~~esbuild~esbuild_linux-x64/launcher.sh '--esbuild_args=typescript/bundle.args.json'

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
bazel-out/k8-opt-exec-ST-4e761c9674ba/bin/external/aspect_rules_esbuild~~esbuild~esbuild_linux-x64/launcher.sh: line 162: uname: command not found
bazel-out/k8-opt-exec-ST-4e761c9674ba/bin/external/aspect_rules_esbuild~~esbuild~esbuild_linux-x64/launcher.sh: line 483: dirname: command not found
Target //typescript:bundle failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 15.212s, Critical Path: 0.04s
INFO: 2 processes: 2 internal.
ERROR: Build did NOT complete successfully

@Strum355
Copy link
Contributor

Strum355 commented Jun 5, 2024

Ah right yes, this is most likely a case of the "fallback" from the actions path patch that we've re-added locally for bazel 7 🤦 https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/dev/nix/bazel.nix?L21-50
Im able to repro with your instructions

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

Successfully merging this pull request may close these issues.

2 participants