Importing a package in an ancestor package instance, then evaluating it in a sub folder #3629
Replies: 2 comments 1 reply
-
cue export "broken.io:a" will work... Thats an answer i think but wont close discussion just yet to leave some space for other suggestions |
Beta Was this translation helpful? Give feedback.
-
Thanks for the question, @WaywardWizard. I think you have simply run into a bug here, which I have raised over at #3640. A couple of thoughts/comments looking at your example:
This should be the behaviour of CUE by default today and you can rely on this. Please raise issues for any bugs you find, like the one you uncovered in #3640. Please note that in #2000 we might change the default behaviour to not load ancestor directories by default. Whilst it fits the use case that you want here, it isn't always what people want. And the fact that it's not possible to "turn off" that behaviour today is a problem for many.
This should be possible, as my repro in #3640 demonstrates. The use of Finally, thank you for taking the time to create such a detailed repro. As you can see from the issue I raised in #3640, repros that involve multiple files can most easily be communicated via a I'll leave you to close this discussion, or ask further questions. |
Beta Was this translation helpful? Give feedback.
-
Use Case
Configuration goes with code. I want to put cue files in my directory heirarchy, and fill them with configuration relevant to the directory in which they are found.
Later, i want to do something with that configuration. For example use it inside a Makefile. If i run cue in a directory, for a package, i want to 'see' all of the unified configuration for that package from all ancestor directories up to the module root regardless of wether or not there is a cue file for that package in the current directory.
Perhaps i need to rethink how i am using cue abit.
Problem
I want to be able to evaluate a cue package (a), in some subdirectory of my cue module (./test), where in some ancestor directory (.) instance of that package (a) another package (b) in the same module (broken.io) is imported. Where in the leaf directory (./test) there is no cue file in the package (a) i am trying to evaluate.
I dont want to specify the module and path to some subfolder to explicitly define the package instance i am evaluating. I want cue to know the package instance is for the directory in which it is being run regardless of wether or not there is a cue file belonging to the package of interest in the current directory.
Problem Demonstration
But am getting this error. I have distilled the problem down to the basics. See my example;
mkdir test; cue mod init "broken.io";touch {a,b}.cue test/c.cue;
Yields the following;
With file contents (commands writing content to file omitted);
a.cue
b.cue
c.cue
When i
pushd test; cue export :a
I get
And try;
popd;cue export :a
Yielding
As expected.
Thoughts
I think cue is expecting this package to be a dependency of the module rather than an internal package, it searches for the dependency cue.mod rather than the module filetree, cannot find it and fails.
Question
What is going wrong? Why cant i cue export in the subdirectory?
Beta Was this translation helpful? Give feedback.
All reactions