From a9bef14e8dabcd298e239150b1fb16f4e89a7dd9 Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Wed, 28 Sep 2022 15:07:46 -0400 Subject: [PATCH] Set bazel's HOME to an absolute path. Bazel at HEAD has a bug which causes Bazel to crash when HOME is set to a relative path. We circumvent this bug by specifying an absolute path. Also added some documentation on the significance of setting this HOME value. Bug: 248104019 Test: Presubmits Test: Verified `m --bazel-mode-dev nothing` continues to pass with Bazel@HEAD Change-Id: Id05c8dc322c8cca04f3d1caf44f5b04ffa96fd3b --- ui/build/soong.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/build/soong.go b/ui/build/soong.go index 3ef77c7a6..ac00fe61f 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -381,7 +381,9 @@ func runSoong(ctx Context, config Config) { soongBuildEnv.Set("TOP", os.Getenv("TOP")) // For Bazel mixed builds. soongBuildEnv.Set("BAZEL_PATH", "./tools/bazel") - soongBuildEnv.Set("BAZEL_HOME", filepath.Join(config.BazelOutDir(), "bazelhome")) + // Bazel's HOME var is set to an output subdirectory which doesn't exist. This + // prevents Bazel from file I/O in the actual user HOME directory. + soongBuildEnv.Set("BAZEL_HOME", absPath(ctx, filepath.Join(config.BazelOutDir(), "bazelhome"))) soongBuildEnv.Set("BAZEL_OUTPUT_BASE", filepath.Join(config.BazelOutDir(), "output")) soongBuildEnv.Set("BAZEL_WORKSPACE", absPath(ctx, ".")) soongBuildEnv.Set("BAZEL_METRICS_DIR", config.BazelMetricsDir())