`XcodeLocalEnvProvider` can't handle the same environment variable in host and target `action_envs`
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
```
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ActionLookupData0{actionLookupKey=ConfiguredTargetKey{label=@@rules_rust++crate+crates__getrandom-0.3.1//:_bs, config=BuildConfigurationKey[ec1284b9d4526f1d880530efbd95cc80af23a4b177891f6d0f57c74222c797a9]}, actionIndex=0}' (requested by nodes 'ArtifactNestedSetKey[2]@559009211', 'File:[[]bazel-out/darwin_arm64-fastbuild/bin]external/rules_rust++crate+crates__getrandom-0.3.1/_bs.cargo_runfiles', 'ArtifactNestedSetKey[3]@611726113', 'ArtifactNestedSetKey[7]@706213338', 'ArtifactNestedSetKey[5]@536078302', 'File:[[]bazel-out/darwin_arm64-fastbuild/bin]external/rules_rust++crate+crates__getrandom-0.3.1/_bs.out_dir') at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:547)
at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:435)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Multiple entries with same key: SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk and SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk
at com.google.common.collect.ImmutableMap.conflictException(ImmutableMap.java:382)
at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:376)
at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:249)
at com.google.common.collect.RegularImmutableMap.fromEntryArrayCheckingBucketOverflow(RegularImmutableMap.java:136)
at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:98)
at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:579)
at com.google.common.collect.ImmutableMap$Builder.buildOrThrow(ImmutableMap.java:607)
at com.google.devtools.build.lib.exec.local.XcodeLocalEnvProvider.rewriteLocalEnv(XcodeLocalEnvProvider.java:103)
at com.google.devtools.build.lib.sandbox.DarwinSandboxedSpawnRunner.prepareSpawn(DarwinSandboxedSpawnRunner.java:219)
at com.google.devtools.build.lib.sandbox.AbstractSandboxSpawnRunner.exec(AbstractSandboxSpawnRunner.java:112)
at com.google.devtools.build.lib.sandbox.SandboxModule$SandboxFallbackSpawnRunner.exec(SandboxModule.java:479)
at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:159)
at com.google.devtools.build.lib.dynamic.LocalBranch.runSpawnLocally(LocalBranch.java:129)
at com.google.devtools.build.lib.dynamic.LocalBranch.runLocally(LocalBranch.java:95)
at com.google.devtools.build.lib.dynamic.LocalBranch.callImpl(LocalBranch.java:186)
at com.google.devtools.build.lib.dynamic.Branch.call(Branch.java:188)
at com.google.devtools.build.lib.dynamic.Branch.call(Branch.java:43)
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
```
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
--host_action_env=SDKROOT=...
--action_env=SDKROOT=...
### Which operating system are you running Bazel on?
macOS
### What is the output of `bazel info release`?
release 8.1.1
Contributor guide
Research direction
Start with XcodeLocalEnvProvider.java, especially rewriteLocalEnv, and reproduce the failure using both --host_action_env=SDKROOT=... and --action_env=SDKROOT=.... Trace how DarwinSandboxedSpawnRunner passes the environment through; done means the duplicate SDKROOT configuration no longer causes the ImmutableMap conflict.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, macos
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100