Skip to content

dagger install should not allow duplicate deps #8821

Closed

Description

@jedevc

It's possible to have multiple dependencies with the same name in dagger.json:

$ dagger init --name=test --sdk=go
$ dagger install github.com/shykes/gha
$ dagger install github.com/heuritech/gha

The resulting dagger.json:

{
  "name": "test",
  "sdk": "go",
  "dependencies": [
    {
      "name": "gha",
      "source": "github.com/heuritech/gha@strategy",
      "pin": "f0c4da95fb3e7e5351d17dfb1d20362d3ae8b2a2"
    },
    {
      "name": "gha",
      "source": "github.com/shykes/gha",
      "pin": "f6c91e490043946d71100645be8253471ba626bd"
    }
  ],
  "source": ".",
  "engineVersion": "v0.13.6"
}

This is happening because the existing de-duping logic only handles the "symbolic" name: github.com/heuritech/gha and github.com/shykes/gha - we're entirely ignoring the names.

// figure out the set of deps, keyed by their symbolic ref string, which de-dupes
// equivalent sources at different versions, preferring the version provided
// in the dependencies arg here
depSet := make(map[string]dagql.Instance[*core.ModuleDependency])
for _, dep := range existingDeps {
symbolic, err := dep.Self.Source.Self.Symbolic()
if err != nil {
return nil, fmt.Errorf("failed to get symbolic source ref: %w", err)
}
depSet[symbolic] = dep
}
for _, dep := range newDeps {
symbolic, err := dep.Self.Source.Self.Symbolic()
if err != nil {
return nil, fmt.Errorf("failed to get symbolic source ref: %w", err)
}
depSet[symbolic] = dep
}

Activity

  1. added
    kind/bug
    area/engine
    on Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/enginekind/bugkind/external-help

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions