Skip to content

Commit

Permalink
Give instruction in error message about how to update lockfile
Browse files Browse the repository at this point in the history
RELNOTES:None
PiperOrigin-RevId: 564455662
Change-Id: I54eb6fcae8ea471e37f7149229bc982850343df8
  • Loading branch information
meteorcloudy authored and copybara-github committed Sep 11, 2023
1 parent ffe595c commit acb38a6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public SkyValue compute(SkyKey skyKey, Environment env)
throw new BazelDepGraphFunctionException(
ExternalDepsException.withMessage(
Code.BAD_MODULE,
"Lock file is no longer up-to-date because: %s",
"Lock file is no longer up-to-date because: %s. "
+ "Please run `bazel mod deps --lockfile_mode=update` to update your lockfile.",
String.join(", ", diffLockfile)),
Transience.PERSISTENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ public ImmutableList<String> getModuleAndFlagsDiff(
ImmutableList.Builder<String> moduleDiff = new ImmutableList.Builder<>();
if (getLockFileVersion() != BazelLockFileValue.LOCK_FILE_VERSION) {
return moduleDiff
.add(
"the version of the lockfile is not compatible with the current Bazel, please run"
+ " with '--lockfile_mode=update'")
.add("the version of the lockfile is not compatible with the current Bazel")
.build();
}
if (!moduleFileHash.equals(getModuleFileHash())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ private SingleExtensionEvalValue tryGettingValueFromLockFile(
throw new SingleExtensionEvalFunctionException(
ExternalDepsException.withMessage(
Code.BAD_MODULE,
"Lock file is no longer up-to-date because: %s",
"Lock file is no longer up-to-date because: %s. "
+ "Please run `bazel mod deps --lockfile_mode=update` to update your lockfile.",
String.join(", ", extDiff)),
Transience.PERSISTENT);
}
Expand Down
16 changes: 10 additions & 6 deletions src/test/py/bazel/bzlmod/bazel_lockfile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def testLockfileErrorMode(self):
'ERROR: Error computing the main repository mapping: Lock file is'
' no longer up-to-date because: the root MODULE.bazel has been'
' modified, the value of --check_direct_dependencies flag has'
' been modified'
' been modified. Please run'
' `bazel mod deps --lockfile_mode=update` to update your lockfile.'
),
stderr,
)
Expand Down Expand Up @@ -246,7 +247,8 @@ def testLocalOverrideWithErrorMode(self):
(
'ERROR: Error computing the main repository mapping: Lock file is'
' no longer up-to-date because: The MODULE.bazel file has changed'
' for the overriden module: bar'
' for the overriden module: bar. Please run'
' `bazel mod deps --lockfile_mode=update` to update your lockfile.'
),
stderr,
)
Expand Down Expand Up @@ -572,7 +574,8 @@ def testUpdateModuleExtensionErrorMode(self):
'implementation of the extension '
"'ModuleExtensionId{bzlFileLabel=//:extension.bzl, "
"extensionName=lockfile_ext, isolationKey=Optional.empty}' or one "
'of its transitive .bzl files has changed'
'of its transitive .bzl files has changed. Please run'
' `bazel mod deps --lockfile_mode=update` to update your lockfile.'
),
stderr,
)
Expand Down Expand Up @@ -758,7 +761,8 @@ def testChangeEnvVariableInErrorMode(self):
' variables the extension'
" 'ModuleExtensionId{bzlFileLabel=//:extension.bzl,"
" extensionName=lockfile_ext, isolationKey=Optional.empty}' depends"
' on (or their values) have changed'
' on (or their values) have changed. Please run'
' `bazel mod deps --lockfile_mode=update` to update your lockfile.'
),
stderr,
)
Expand Down Expand Up @@ -827,8 +831,8 @@ def testOldVersion(self):
(
'ERROR: Error computing the main repository mapping: Lock file is'
' no longer up-to-date because: the version of the lockfile is not'
' compatible with the current Bazel, please run with'
" '--lockfile_mode=update'"
' compatible with the current Bazel. Please run'
' `bazel mod deps --lockfile_mode=update` to update your lockfile.'
),
stderr,
)
Expand Down

0 comments on commit acb38a6

Please sign in to comment.