Skip to content

Commit

Permalink
cmd/cue: improve error message when modules experiment not enabled
Browse files Browse the repository at this point in the history
When `cue mod tidy` or `cue mod publish` are run, which both require
modules to be enabled, the current error seems to indicate that
there is no registry configured, even though there's a default registry
fallback, so that shouldn't be necessary.

Change the error message to suggest setting CUE_EXPERIMENT=modules
instead.

Signed-off-by: Roger Peppe <[email protected]>
Change-Id: I57348e595154ab99a0a6ada09fa80584a62958dc
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1177130
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
rogpeppe committed Feb 20, 2024
1 parent bd96660 commit d1f1793
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/cue/cmd/modpublish.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func runModUpload(cmd *Command, args []string) error {
return err
}
if resolver == nil {
return fmt.Errorf("no registry configured to publish to")
return fmt.Errorf("modules experiment not enabled (enable with CUE_EXPERIMENT=modules)")
}
modRoot, err := findModuleRoot()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cue/cmd/modtidy.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func runModTidy(cmd *Command, args []string) error {
return err
}
if reg == nil {
return fmt.Errorf("no module registry configured")
return fmt.Errorf("modules experiment not enabled (enable with CUE_EXPERIMENT=modules)")
}
ctx := context.Background()
modRoot, err := findModuleRoot()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
! exec cue mod publish v1.0.0
cmp stderr want-stderr
-- want-stderr --
modules experiment not enabled (enable with CUE_EXPERIMENT=modules)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
! exec cue mod tidy
cmp stderr want-stderr
-- want-stderr --
modules experiment not enabled (enable with CUE_EXPERIMENT=modules)

0 comments on commit d1f1793

Please sign in to comment.