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
diff --git a/ui/build/soong.go b/ui/build/soong.go
index 3ef77c7..ac00fe6 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -381,7 +381,9 @@
 	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())