cue
cue copied to clipboard
CUE modules that have a gen directory can't be used
What version of CUE are you using (cue version)?
cue version v0.9.0-rc.1
go version go1.22.1
-buildmode exe
-compiler gc
DefaultGODEBUG httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
CGO_ENABLED 1
GOARCH amd64
GOOS linux
GOAMD64 v1
cue.lang.version v0.9.0
Does this issue reproduce with the latest stable release?
yes
What did you do?
In a new directory, create a module and add a dependency:
cue mod init github.com/vikstrous/cuek8stest
cue mod get github.com/vikstrous/cuek8s
Create a file: test.cue
package cuek8stest
import "github.com/vikstrous/cuek8s"
hello: cuek8s.#Hello
service: cuek8s.#Service
Then run cue eval
What did you expect to see?
it shouldn't error
What did you see instead?
github.com/vikstrous/[email protected]/vikstrous/cuek8s: import failed: import failed: cannot find package "k8s.io/api/core/v1": cannot find module providing package k8s.io/api/core/v1:
./test.cue:3:8
../.cache/cue/mod/extract/github.com/vikstrous/[email protected]/hello.cue:3:8
I'm seeing something similar as well
Same here.
I'm planning to start trying to work around this by rewriting package paths and moving the gen packages out of the gen directory. To reproduce this issue, use version v0.0.8 of https://github.com/vikstrous/cuek8s
This is the workaround: https://github.com/vikstrous/cuek8s/blob/master/generate.sh
I am also encountering this issue with a module published using 0.9.2 and source: kind: "self".
Note that this behaviour is documented in the introduction to the CUE modules reference:
as a transitionary measure, the CUE tool still supports the import of packages present in the
cue.mod/pkg,cue.mod/usrandcue.mod/gendirectories. This only applies to the main module, and if there is any ambiguity with respect to regular module dependencies an “ambiguous import” error will be reported.
Note the "as a transitionary measure" caveat above. Eventually, it's possible/probable that support for the gen, usr and pkg directories will be dropped in favour of regular published packages.
Closing this issue as everything seems to be functioning as intended.