Skip to content

cmd/cue: hidden files affect the loader's choice of package to evaluate #3795

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

Closed
jpluscplusm opened this issue Mar 6, 2025 · 1 comment
Closed
Labels

Comments

@jpluscplusm
Copy link
Collaborator

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

$ cue version
cue version v0.13.0-0.dev.0.20250306134408-5d2da079a295

go version go1.24.0
      -buildmode exe
       -compiler gc
  DefaultGODEBUG gotestjsonbuildtext=1,multipathtcp=0,randseednop=0,rsa1024min=0,tlsmlkem=0,x509rsacrt=0,x509usepolicies=0
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.13.0

Does this issue reproduce with the latest stable release?

Yes, v0.12.0.

What did you do?

# file & hidden file with same package identifier and conflicting data.
cd $WORK/A
exec cue export
cmp stdout $WORK/A.gold

# file & hidden file with different package identifiers.
cd $WORK/B
exec cue export
cmp stdout $WORK/B.gold

-- A/.foo.cue --
package A
x: 1
-- A/file.cue --
package A
x: 2
-- B/.foo.cue --
package foo
x: 3
-- B/file.cue --
package B
x: 3
-- A.gold --
{
    "x": 2
}
-- B.gold --
{
    "x": 3
}

What did you expect to see?

A passing test, indicating that hidden CUE files (with filenames that start with a period) are ignored -- as is demonstrated in the first test where a hidden CUE file contains data that conflicts with data in a non-hidden CUE file.

What did you see instead?

# file & hidden file with same package identifier and conflicting data. (0.019s)
# file & hidden file with different package identifiers. (0.017s)
> cd $WORK/B
$WORK/B
> exec cue export
[stderr]
found packages "foo" (.foo.cue) and "B" (file.cue) in "."
[exit status 1]
FAIL: excluded-hidden-files-affect-loader.txtar:8: unexpected command failure
@jpluscplusm jpluscplusm added NeedsInvestigation Triage Requires triage/attention labels Mar 6, 2025
@myitcv myitcv added NeedsFix and removed Triage Requires triage/attention NeedsInvestigation labels Mar 8, 2025
@myitcv
Copy link
Member

myitcv commented Mar 8, 2025

This seems like a good quality of life improvement.

We should also fix the disregarding of files because of build constraints:

exec cue export

-- cue.mod/module.cue --
module: "mod.com"
language: {
	version: "v0.12.0"
}
-- deps.cue --
@if(deps)
package deps

rubbish
-- x.cue --
package x

x: 5

i.e. my expectation is that this test should pass because the deps package does not, in effect, exist without the -t deps flag being specified.

cueckoo pushed a commit that referenced this issue Mar 12, 2025
This CL adds some failing test cases for #3795. The fix will come
in subsequent CLs.

Signed-off-by: Roger Peppe <[email protected]>
Change-Id: I33edf403f0ad1a99c87a9b0544f4993a75059182
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211241
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
cueckoo pushed a commit that referenced this issue Mar 12, 2025
The `modimports` logic should exclude "hidden" CUE files
just as it excludes directories.

For #3795

Signed-off-by: Roger Peppe <[email protected]>
Change-Id: I9219cd58cf7a02adaed5774af71669596849832e
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211242
Reviewed-by: Daniel Martí <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants