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.14k stars 294 forks source link

cmd/vet: argument order matters when CUE content is a package reference #2273

Open jpluscplusm opened 1 year ago

jpluscplusm commented 1 year ago

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

cue version v0.5.0-beta.5

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

Does this issue reproduce with the latest stable release?

Yes.

What did you do?

I use the cue vet command to test non-CUE files. I use the cue vet --help output to tell me how to specify the input.

The help text only mentions referring to .cue files explicitly, not packages, but because I know that most cue subcommands work in both "file" and "package" mode, I give "package mode" a try, and it works:

$ cue vet cue.test:schema pass.yml
$ ๐Ÿ‘ 

Later, in a different project, I try to replicate this arrangement -- that I know has worked before -- but it fails with a seemingly-unrelated message:

$ cue vet pass.yml cue.test:schema 
cannot combine scope with file
$ ๐Ÿ‘Ž 

I become discouraged.


Here's a txtar repro with -- to my mind -- 4 equivalent commands. The first 3 succeed; the last 1 fails.

exec cue vet pass.yml schema.cue
exec cue vet schema.cue pass.yml
exec cue vet cue.test:schema pass.yml
exec cue vet pass.yml cue.test:schema
-- cue.mod/module.cue --
module: "cue.test"
-- schema.cue --
package schema

a: int
b: string
-- pass.yml --
a: 123
b: "a string"

What did you expect to see?

I expected the order of the params given to cue vet not to matter.

What did you see instead?

The order of the params mattered; and gave me an inscrutable & discouraging error message.

myitcv commented 1 year ago

Chatting with @mpvl and @mvdan, this actually feels like it could be a bug. Leaving for more investigation in v0.6.x if time allows. @jpluscplusm - please shout if this is actually a more pressing issue than our prioritisation would suggest!