dagger/dagger · error

failed to load contextual git repository: %w

Error message

failed to load contextual git repository: %w

What it means

For a plain git module source, loading the contextual GitRepository by selecting git(url, commit, ref) from the root failed. The clone ref, pinned commit, or ref name could not be resolved — e.g. network/auth failure, deleted commit, or unknown ref — and the error wraps the underlying git load failure.

Source

Thrown at core/modulesource.go:1950

		return inst, nil
	}

	if src.Kind == ModuleSourceKindGit {
		// easy, we're running a git repo
		err := dag.Select(ctx, dag.Root(), &inst,
			dagql.Selector{
				Field: "git",
				Args: []dagql.NamedInput{
					{Name: "url", Value: dagql.String(src.Git.CloneRef)},
					// NOTE: pin HEAD to the module's git commit and ref
					// this matches the behavior of calling a checked out local source module
					{Name: "commit", Value: dagql.String(src.Git.Commit)},
					{Name: "ref", Value: dagql.String(src.Git.Ref)},
				},
			},
		)
		if err != nil {
			return inst, fmt.Errorf("failed to load contextual git repository: %w", err)
		}
		return inst, nil
	}

	// bit harder, this is actually a local directory
	dir, err := src.LoadContextDir(ctx, dag, "/", CopyFilter{
		Gitignore: true,
	})
	if err != nil {
		return inst, fmt.Errorf("failed to load contextual git: %w", err)
	}

	if src.Kind == ModuleSourceKindLocal {
		// The engine never interprets the host checkout's raw git layout
		// (worktree/submodule pointer files, commondirs, separate git dirs):
		// replace whatever .git the synced tree carries with a canonical
		// reconstruction of the checkout's repository, packed by the client's
		// own git. Route through the owning client, as loading host paths does.

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Verify the git clone URL is reachable (network and credentials)
  2. Check that the pinned commit and ref still exist in the repository
  3. Inspect the wrapped error for the specific clone/checkout failure
  4. Ensure required service bindings or auth tokens for the repo are configured
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at core/modulesource.go:1950 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/a85f70dc787cdad3. Report an issue: GitHub.