Skip to content

Commit

Permalink
fix(bazel): Always disable the disk cache
Browse files Browse the repository at this point in the history
When the disk-cache is set via `.bazelrc` to a non-existing directory,
`bazel mod graph` fails with a complaint about permissions, which in
turn makes the analysis fail.

The disk cache is a build cache which seems to target speeding up
builds in case of code changes (such as switching branches) [1]. During
ORT analysis code changes are not in play, so the disk cache seems to
be of little use anyway. Simply disable it to avoid running into that
permission issue.

Fixes: #8802.

[1] https://stackoverflow.com/questions/61282419/bazel-how-outputroot-and-disk-cache-relate-regarding-local-caching

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau authored and sschuberth committed Jun 28, 2024
1 parent fd6b3fb commit a6894a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --disk_cache=/non-existing-dir
5 changes: 4 additions & 1 deletion plugins/package-managers/bazel/src/main/kotlin/Bazel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ class Bazel(
}.getOrNull()

private fun getDependencyGraph(projectDir: File, depDirectives: Map<String, BazelDepDirective>): Set<Scope> {
val modGraphProcess = run("mod", "graph", "--output", "json", workingDir = projectDir)
val modGraphProcess = run(
"mod", "graph", "--output", "json", "--disk_cache=", workingDir = projectDir
)

val node = JSON.decodeFromString<ModuleGraphNode>(modGraphProcess.stdout)
val devDeps = node.dependencies.filter { depDirectives[it.key]?.devDependency == true }.toSet()
val mainDeps = node.dependencies.toSet() - devDeps
Expand Down

0 comments on commit a6894a2

Please sign in to comment.