Skip to content

Commit 082fd40

Browse files
committed
internal/mod/modload: better error message for not-found module
When a module isn't found we should give an error that reflects that fact. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I9227dad4f241bc696502bda0ed699a59dbb8ec29 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1201493 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent f1b72f5 commit 082fd40

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cmd/cue/cmd/testdata/script/modtidy_not_found.txtar

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module: "main.org@v0"
66
language: version: "v0.10.0"
77

88
-- want-stderr --
9-
path "other.test" has no major version
9+
no versions found for module other.test@v0
1010
-- main.cue --
1111
package main
1212

internal/mod/modload/update.go

+4
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ func resolveUpdateVersions(ctx context.Context, reg Registry, rs *modrequirement
150150
possibleVersions = append(possibleVersions, v)
151151
}
152152
}
153+
if len(possibleVersions) == 0 {
154+
setError(fmt.Errorf("no versions found for module %s", v))
155+
return
156+
}
153157
chosen := latestVersion(possibleVersions)
154158
mv, err := module.NewVersion(mpath, chosen)
155159
if err != nil {

0 commit comments

Comments
 (0)