cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.01k stars 283 forks source link

cmd/cue: mod init's DX of "non-conforming path ..." is confusing #3022

Closed jpluscplusm closed 1 month ago

jpluscplusm commented 4 months ago

What version of CUE are you using (cue version)?

$ cue version
cue version v0.8.1

go version go1.22.1
      -buildmode exe
       -compiler gc
       -trimpath true
     CGO_ENABLED 0
          GOARCH amd64
            GOOS linux
         GOAMD64 v1

Does this issue reproduce with the latest stable release?

Yes, 0.8.1.

What did you do?

I opened https://github.com/cue-lang/cue/issues/3021 because I didn't know that module paths now need to be lower case, and nothing outside the experimentally-scoped documentation at https://cuelang.org/docs/reference/modules/ mentions this.

When attempting to initialise a module with a path that contains upper case letters, this is the current DX:

$ cue mod init github.com/MyUsername/MyRepoName
invalid module name "github.com/MyUsername/MyRepoName": non-conforming path "github.com/MyUsername/MyRepoName/

This is confusing, especially as the only guidance I can recall us giving around module names is that they should generally reflect domains under the user's control or (on shared domains) paths under the user's control. The user "MyUserName", above, doesn't explicitly control the namespace github.com/myusername/. In this error message we should give them clear guidance about what's wrong with their proposed module name; and in the case of it being a case issue we should link to guidance about when it's safe to fold case. I.e. there will be services out there where user MyUserName does not control service.example/myusername/, and we should be cautious in not providing blanket "just lower case the path" guidance.

What did you expect to see?

What did you see instead?

$ cue mod init github.com/MyUsername/MyRepoName
invalid module name "github.com/MyUsername/MyRepoName": non-conforming path "github.com/MyUsername/MyRepoName/
myitcv commented 3 months ago
  • An indication of the explicit problem with the module name chosen
  • Guidance about how to move forward with a correct module name

Agreed - we can do better here, perhaps indeed pointing people towards https://cuelang.org/docs/reference/modules/#module-path