diff --git a/cmd/cue/cmd/testdata/script/modtidy_not_found.txtar b/cmd/cue/cmd/testdata/script/modtidy_not_found.txtar index 85c3a7e3928..cad398fab9f 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_not_found.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_not_found.txtar @@ -6,7 +6,7 @@ module: "main.org@v0" language: version: "v0.10.0" -- want-stderr -- -path "other.test" has no major version +no versions found for module other.test@v0 -- main.cue -- package main diff --git a/internal/mod/modload/update.go b/internal/mod/modload/update.go index 9ab8c1944cb..28b117811e6 100644 --- a/internal/mod/modload/update.go +++ b/internal/mod/modload/update.go @@ -150,6 +150,10 @@ func resolveUpdateVersions(ctx context.Context, reg Registry, rs *modrequirement possibleVersions = append(possibleVersions, v) } } + if len(possibleVersions) == 0 { + setError(fmt.Errorf("no versions found for module %s", v)) + return + } chosen := latestVersion(possibleVersions) mv, err := module.NewVersion(mpath, chosen) if err != nil {