Skip to content

Commit

Permalink
fix(bazel): Force the generation of a MODULE.bazel.lock file
Browse files Browse the repository at this point in the history
Some projects can explicitly disable the lock file generation by putting
'common --lockfile_mode=off' in their '.bazelrc'. In such projects, running
'bazel mod graph' does not generate a lock file anymore if it is missing.
Since ORT requires a lock file to be present, this commit adds a flag to
force the (re)generation of the lock file. See [1].

[1]: https://bazel.build/versions/7.1.0/external/lockfile

Signed-off-by: Nicolas Nobelis <[email protected]>
  • Loading branch information
nnobelis authored and sschuberth committed Sep 26, 2024
1 parent ad1329b commit a980b5d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion plugins/package-managers/bazel/src/main/kotlin/Bazel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,15 @@ class Bazel(
depDirectives: Map<String, BazelDepDirective>,
archiveOverrides: Map<String, ArchiveOverride>
): Set<Scope> {
val process = run("mod", "graph", "--output", "json", "--disk_cache=", workingDir = projectDir)
val process = run(
"mod",
"graph",
"--output",
"json",
"--disk_cache=",
"--lockfile_mode=update",
workingDir = projectDir
)
val mainModule = process.stdout.parseBazelModule()
val (mainDeps, devDeps) = mainModule.dependencies.map { module ->
val name = module.name ?: module.key.substringBefore("@", "")
Expand Down

0 comments on commit a980b5d

Please sign in to comment.