Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

import failed: no CUE files in k8s.io/api/core/v1 #515

Closed
weberc2-tempus opened this issue Sep 11, 2020 · 7 comments
Closed

import failed: no CUE files in k8s.io/api/core/v1 #515

weberc2-tempus opened this issue Sep 11, 2020 · 7 comments
Labels
get go issues related to cue get go roadmap/errors Related to improving error messages.

Comments

@weberc2-tempus
Copy link

weberc2-tempus commented Sep 11, 2020

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

$ cue version
cue version 0.2.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

Following the tutorial, I did

$ cue mod init foobar
invalid host name "foobar"
$ cue mod init
$ echo 'import "k8s.io/api/core/v1"' > main.cue
$ echo 'services: [string]: v1.#Service' >> main.cue
$ cue get go k8s.io/api/core/v1
$ cue eval
build constraints exclude all CUE files in . (ignored: main.cue)
$ cue eval main.cue
import failed: no CUE files in k8s.io/api/core/v1:
    ./main.cue:1:8

What did you expect to see? / What did you see instead?

I seem to be misunderstanding a few things (I'm brand new to cue, so I assume I'm missing something obvious):

  1. Why can't I pass a module name argument to cue mod init per the documentation?
  2. Why does cue eval ignore main.cue?
  3. Why does the import fail at the end? This is pretty much straight from the example on import Go definitions unless I've made an error somehow?
@mpvl
Copy link
Contributor

mpvl commented Sep 11, 2020

CUE files without a package clause need to be listed explicitly on the command line. So if you add a package clause at the top of the file you're good.

This should be mentioned in a better error message.

@mpvl mpvl added roadmap/errors Related to improving error messages. and removed NeedsInvestigation labels Sep 11, 2020
@mpvl
Copy link
Contributor

mpvl commented Sep 11, 2020

also, run go get k8s.io/api/core/v1 first.

@weberc2-tempus
Copy link
Author

CUE files without a package clause need to be listed explicitly on the command line. So if you add a package clause at the top of the file you're good. This should be mentioned in a better error message.

Ah, thanks very much.

also, run go get k8s.io/api/core/v1 first.

Does this mean "run go get k8s.io/... before cue mod init"? Because I am running it before cue eval fwiw.

@verdverm
Copy link
Contributor

verdverm commented Oct 21, 2020

I think those two commands order does not matter, and that the go get needs to happen before cue get go

cue mod init hof.io/foo  // this needs to be a domain/pkg
go get k8s.io/api/...      // also needs domain/pkg format
cue get go k8s.io/api/core/v1

this did not actually work, to get the files, I had to additionally run the following

go get k8s.io/api/core/v1
cue get go k8s.io/api/core/v1

I now have the files there

It seems that the initial directory specified may need to have Go files / types that Cue can process? (@mpvl ?)

It does look like cue get go k8s.io/api/... works

@jpugliesi
Copy link

jpugliesi commented Dec 8, 2020

I'm seeing the same issue as described by @weberc2-tempus. Here's my setup:

file structure:

$ tree -L 2
.
├── cue.mod
│   ├── gen
│   ├── module.cue
│   ├── pkg
│   └── usr
└── services
    ├── main.cue

cue.mod/module.cue:

module: "github.com/jpugliesi/infrastructure"

Attempting to install the k8s packages

go get k8s.io/api/apps/v1
cue get go k8s.io/api/apps/v1
cue get go k8s.io/api/core/v1

listing files in cue.mod (note there aren't any generated files):

$ find ./cue.mod
./cue.mod
./cue.mod/usr
./cue.mod/gen
./cue.mod/gen/k8s.io
./cue.mod/gen/k8s.io/api
./cue.mod/gen/k8s.io/api/core
./cue.mod/gen/k8s.io/api/core/v1
./cue.mod/gen/k8s.io/api/apps
./cue.mod/gen/k8s.io/api/apps/v1
./cue.mod/module.cue
./cue.mod/pkg

main.cue:

import (
  "k8s.io/api/core/v1"
  apps_v1 "k8s.io/api/apps/v1"
)

service: [string]:     v1.#Service
deployment: [string]:  apps_v1.#Deployment
daemonSet: [string]:   apps_v1.#DaemonSet
statefulSet: [string]: apps_v1.#StatefulSet

Error:

$ cue eval -c main.cue
import failed: no CUE files in k8s.io/api/apps/v1:
    ./main.cue:3:3

Cue Version Info

$ cue version
cue version v0.3.0-alpha5.0.20201207144701-6de877a926cf darwin/amd64

@mpvl mpvl added the get go issues related to cue get go label Jan 19, 2021
@myitcv
Copy link
Contributor

myitcv commented Jan 19, 2021

@jpugliesi - from the looks of your repro you are missing a go mod init ABC step, hence the go get succeeds but in the void.

@verdverm - see #645 for the issue regarding cue mod init being overly restrictive on the module name.

@weberc2-tempus - this issue generally feels like a symptom of the the various issues I summarised in
#621 (comment). On the basis we have a clear path forward via #621 (comment), I'm going to close this issue effectively as a duplicate of #621 (preferring that issue because of the more complete commentary)

Please feel free to raise any further questions/issues over there, or in a separate issue if you think it a separate issue.

Thanks

@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#515.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
get go issues related to cue get go roadmap/errors Related to improving error messages.
Projects
None yet
Development

No branches or pull requests

6 participants