-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/cue: path resolution issue for get go generated files #452
Comments
Original reply by @mpvl in cuelang/cue#452 (comment) One thing to test is whether it is the name It is a bit hard to piece out what your setup from the text though. Easier would be to have a txtar reproducer (can use |
Original reply by @seh in cuelang/cue#452 (comment) This pkg directory came up in this Slack discussion in the "language" channel. Is this special treatment of the top-level pkg directory deprecated? Here's an example that only works when the
I couldn't find any documentation that mentions this treatment, nor could I find where in the CUE source code it handles this case. |
I resolved the same "import failed: cannot find package" error by making sure that the module root defined in txtar to reproduce the error:
The command
Subsequent
|
@errordeveloper - apologies, I missed this issue when you first created it. @grantzvolsky - thanks for the follow up which caused me to see it. Incidentally, @mpvl's reference to a Assuming I have accurately reproduced the scenario described by @errordeveloper, then I don't think this is anything to do with the Firstly, to reproduce the error you are seeing:
gives:
The missing piece in the puzzle here is the Trying with the
gives:
I think the right answer here is to drop the |
@myitcv thanks a lot, I was looking back at this as I'm picking up a new project where I'm going to be using CUE, and just confirmed that |
Correct. I'm not sure That said, I think you're coming at this from the perspective of a Go+CUE project, so onto your next point.
This is an interesting point. I suspect we can't make it optional, but I'm copying @rogpeppe who is looking at modules. |
Originally opened by @errordeveloper in cuelang/cue#452
I have a Go+CUE project, the Go import root is
github.com/isovalent/foo/operator
(i.e. repo isgithub.aaakk.us.kg/isovalent/foo
, and code is inoperator
subdirectory, I shall refer to any files using paths relative to theoperator
subdirectory).I have created subdirectory
cue.mod
andcue.mod/module.cue
contains the following line:I have created Go types defined in subdirectory
api/v1alpha1
, and I generated CUE schema for these types using the following command:I created a CUE file
pkg/template/testassets/template.cue
, which contains:And this is what I am seeing:
I was not able to tell what is really going on, according to the docs it should find the following directory:
Having made a few guesses, I realised that it's looking in the same directory where Go types are, and there no CUE files in that directory.
I was able to confirm this by placing a dummy file
api/v1alpha1/touch.cue
:And running:
Next, I tried to modify
cue.mod/module.cue
and append a string to the path:No I got it working as expected, but it's still quite odd and very confusing. If Go source directories are used during import resolution, why is
go.mod
needed? I suppose this is just a bug.The text was updated successfully, but these errors were encountered: