Skip to content

Commit

Permalink
internal/mod/modload: better error message for not-found module
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rogpeppe committed Sep 19, 2024
1 parent f1b72f5 commit 082fd40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/cue/cmd/testdata/script/modtidy_not_found.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions internal/mod/modload/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 082fd40

Please sign in to comment.