Description of the bug:
When a --repo_env var lacks the value part, Bazel crashes instead of using the value of that variable from the environment.
Starting local Bazel server and connecting to it...
Loading: 0 packages loaded
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'REPOSITORY_DIRECTORY:@debug' (requested by nodes 'IGNORED_PACKAGE_PREFIXES:@debug')
at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:674)
at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NullPointerException: null value in entry: FOO=null
at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:32)
at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:99)
at com.google.common.collect.RegularImmutableMap.fromEntries(RegularImmutableMap.java:73)
at com.google.common.collect.ImmutableMap.copyOf(ImmutableMap.java:460)
at com.google.common.collect.ImmutableMap.copyOf(ImmutableMap.java:433)
at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkRepositoryFunction.fetch(StarlarkRepositoryFunction.java:174)
at com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction.fetchRepository(RepositoryDelegatorFunction.java:415)
at com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction.compute(RepositoryDelegatorFunction.java:349)
at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:590)
... 4 more
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Create a trivial repository_rule that uses the env variable.
───────┬───────────────────────────────────────────────
│ File: BUILD <EMPTY>
│ Size: 0 B
───────┴───────────────────────────────────────────────
───────┬───────────────────────────────────────────────
│ File: main.bzl
│ Size: 198 B
───────┼───────────────────────────────────────────────
1 │
2 │ def _dump_env(ctx):
3 │ val = ctx.os.environ.get("FOO", "nothing")
4 │ print("FOO", val)
5 │ ctx.file("FOO", val)
6 │
7 │
8 │ dump_env = repository_rule(
9 │ implementation = _dump_env,
10 │ local = True,
11 │ )
12 │
───────┴───────────────────────────────────────────────
───────┬───────────────────────────────────────────────
│ File: WORKSPACE
│ Size: 65 B
───────┼───────────────────────────────────────────────
1 │ load("//:main.bzl", "dump_env")
2 │
3 │ dump_env(
4 │ name = "debug",
5 │ )
───────┴───────────────────────────────────────────────
Which operating system are you running Bazel on?
Linux (NixOS)
What is the output of bazel info release?
release 5.1.1- (@Non-Git)
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
Bazel 5.1.1, built with nix, on NixOS.
Not tested yet if this is nix/nixos specific.
What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
Have you found anything relevant by searching the web?
Seems like the feature is used to be broken: #12886
See also #8869
Any other information, logs, or outputs that you want to share?
No response
Description of the bug:
When a --repo_env var lacks the value part, Bazel crashes instead of using the value of that variable from the environment.
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Create a trivial repository_rule that uses the env variable.
Which operating system are you running Bazel on?
Linux (NixOS)
What is the output of
bazel info release?release 5.1.1- (@Non-Git)
If
bazel info releasereturnsdevelopment versionor(@non-git), tell us how you built Bazel.Bazel 5.1.1, built with nix, on NixOS.
Not tested yet if this is nix/nixos specific.
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD?Have you found anything relevant by searching the web?
Seems like the feature is used to be broken: #12886
See also #8869
Any other information, logs, or outputs that you want to share?
No response