Repository navigation
Closed
Description
What is the issue?
I get the following error message when I try to install the Trivy integration:
β― dagger mod install github.com/jpadams/daggerverse/trivy@21f9211e5727a0b6acce8a0ab6c35d01896dc642
β generatedCode ERROR [1.24s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json ERROR [0.64s]
β Error: generate code: template: module.go.tmpl:74:3: executing "_dagger.gen.go/module.go.tmpl" at <ModuleMainSrc>: error calling ModuleMainSrc: cann
β define methods on objects from outside this module
β generating go module: trivy ERROR [0.37s]
β [0.22s] go mod tidy
β writing dagger.gen.go
β writing go.mod
β writing go.sum
β creating directory querybuilder
β writing querybuilder/marshal.go
β writing querybuilder/querybuilder.go
β needs another pass...
β’ Engine: 12d472085f11 (version v0.9.6)
β§ 2.90s β 28 β
11 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule.generatedCode failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Here are the steps to reproduce:
- Clone the Github repositoryhttps://github.com/Cloud-Native-Security/dagger-trivy
- Run: dagger mod init --name=trivy --sdk=go
- Run: dagger mod install github.com/jpadams/daggerverse/trivy@21f9211e5727a0b6acce8a0ab6c35d01896dc642
Dagger version
dagger v0.9.6 (registry.dagger.io/engine) darwin/arm64
Steps to reproduce
Included above
It also relates to the following issue: #6329
the "quick" fix is to avoid running go mod init, because dagger mod init will take care of creating the go.mod file anyway if it doesn't exists, and it will have the "right" go version (the one used by the dagger container)
I tried this but it did not work
As you can see, my go.mod file does not have the minor version: https://github.com/Cloud-Native-Security/dagger-trivy/blob/4238c52dc1e0a66a10de7bbe1f97f8f963de83f1/app/go.mod#L3
Log output
Of the command?
Activity
kpenfound commentedon Jan 17, 2024
This is an interesting one! It looks like the module you're trying to install,
jpadams/daggerverse/trivy, is clashing with the name of your module,trivy. A workaround for now is to name your module in themod initanything elsesipsma commentedon Jan 18, 2024
Yeah this is a tricky case, but not obscure enough to ignore since it's quite annoying to have to rename your own module like this. Due to the fact that transitive dependencies are hidden from dependers, this at least is only a problem when your own module name is the same as a direct dep.
The fundamental problem is even though objects from dependency modules are namespaced, the "main module object" (and associated constructors) are not, so there will be graphql-level conflicts, in addition to possible SDK-specific naming conflicts depending on the SDK.
I've figured for a while we may eventually want to add support for aliasing dependencies, conceptually similar to how most languages allow you to alias imports. That would allow this case to be supported I think. It's obviously not awesome that you'd have to go out of your way to do that (i.e.
dagger mod install foobar --alias blahblahor something), but given this case of "module name is the same name as a direct dep" is likely not too common, I think I'd be okay with it.[-]π Error: failed to automate vcs -- when trying to install different Dagger integrations[/-][+]π Error when dependency has same name as own module[/+]sipsma commentedon Jan 31, 2024
The ability to rename dependencies was implemented in #6386
Leaving this issue open since we still need to doc it :-)