cue icon indicating copy to clipboard operation
cue copied to clipboard

cmd/cue: `cue mod get` cannot update module version if that version is not present in the registry

Open manishajakkula opened this issue 7 months ago • 1 comments

If the module.cue file has a dependency with a non existent / deleted version specified, cue mod get Modulename@latest is not able to fetch the module and fails with the following error

failed to resolve "some/module/path:mycuemodule": cannot fetch some/module/path:[email protected]: module some/module/path:[email protected]: module not found

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

$ cue version

cue version v0.10.1

Does this issue reproduce with the latest stable release?

Yes

What did you do?

What did you expect to see?

  • Updated module.cue with the latest version of the dependency module

What did you see instead?

manishajakkula avatar Jun 11 '25 18:06 manishajakkula

This is indeed an real problem.

Here's a test case suitable for adding as cmd/cue/cmd/testdata/script/modget_version_not_present.txtar:

# Check that cue mod get will upgrade an existing
# dependency when that dependency
# does not currently exist.

exec cue mod get baz.org
exec cue export
cmp stdout want-stdout

-- want-stdout --
{
    "baz.org@v0": "v0.11.0"
}
-- cue.mod/module.cue --
module: "main.org@v0"
language: {
	version: "v0.8.0"
}
deps: {
	"baz.org@v0": {
		v: "v0.10.0"
	}
}

-- main.cue --
package main
import "baz.org:main"

main

-- _registry/baz.org_v0.11.0/cue.mod/module.cue --
module: "baz.org@v0"
language: version: "v0.8.0"

-- _registry/baz.org_v0.11.0/baz.cue --
package main
"baz.org@v0": "v0.11.0"

This fails for me with:

--- FAIL: TestScript (0.02s)
    --- FAIL: TestScript/modget_version_not_present (0.01s)
        testscript.go:584: # Check that cue mod get will upgrade an existing
            # dependency when that dependency
            # does not currently exist. (0.011s)
            > exec cue mod get baz.org
            [stderr]
            cannot determine module graph: [email protected]: module [email protected]: module not found
            [exit status 1]
            FAIL: testdata/script/modget_version_not_present.txtar:5: unexpected command failure

The reason is that internal/mod/modload/update.go resolves the module versions before actually updating the versions.

rogpeppe avatar Jun 12 '25 16:06 rogpeppe