dagger/dagger · error

path %q does not exist in git repo

Error message

path %q does not exist in git repo

What it means

Thrown by findGitModuleConfig when the explicitly given SourceRootSubpath does not exist inside the fetched git repo. This pre-existence check exists so that a wrong subpath cannot find-up to some unrelated module config elsewhere in the repo and appear to succeed.

Source

Thrown at core/schema/modulesource.go:727

		}
		if !found {
			if !allowNotExists {
				return "", false, fmt.Errorf("git module source %q does not contain a dagger config file", gitSrc.AsString())
			}
			return "", false, nil
		}
		gitSrc.ConfigFilename = configFilename
		return filepath.Join(gitSrc.SourceRootSubpath, configFilename), true, nil
	}

	// first validate the given path exists at all, otherwise weird things like
	// `dagger -m github.com/dagger/dagger/not/a/real/dir` can succeed because
	// they find-up to a real module config file
	if gitSrc.SourceRootSubpath != "" {
		if _, exists, err := core.StatFSExists(ctx, statFS, gitSrc.SourceRootSubpath); err != nil {
			return "", false, fmt.Errorf("failed to stat git module source: %w", err)
		} else if !exists {
			return "", false, fmt.Errorf("path %q does not exist in git repo", gitSrc.SourceRootSubpath)
		}
	}

	configDir, configFilename, found, err := findUpModuleConfig(ctx, statFS, filepath.Join("/", gitSrc.SourceRootSubpath))
	if err != nil {
		return "", false, fmt.Errorf("failed to find-up module config: %w", err)
	}
	if !found {
		if !allowNotExists {
			return "", false, fmt.Errorf("git module source %q does not contain a dagger config file", gitSrc.AsString())
		}
		return "", false, nil
	}
	gitSrc.ConfigFilename = configFilename
	gitSrc.SourceRootSubpath = strings.TrimPrefix(configDir, "/")
	return filepath.Join(configDir, configFilename), true, nil
}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Correct the subpath in the module reference to a directory that exists at the resolved ref
  2. Verify the path exists at that ref/tag/branch in the git host UI
  3. Check whether a pin (version/ref) points at an older commit where the path didn't exist
  4. If the module lives at the repo root, drop the subpath entirely

Example fix

// before
dagger -m github.com/dagger/dagger/modules/notreal
// after
dagger -m github.com/dagger/dagger/modules/go
Defensive patterns

Strategy: validation

Validate before calling

// Assert the subpath exists in the repo at the target ref first
const exists = await client.git(repoUrl).ref(ref).tree().directory(subpath)
  .file("dagger.json").exists ? true : true; // use .id() to force resolution
await client.git(repoUrl).ref(ref).tree().directory(subpath).id();

Try / catch

try {
  await client.moduleSource(`${repoUrl}/${subpath}`).load();
} catch (e) {
  if (String(e).includes("does not exist in git repo")) {
    // fix subpath or ref before retrying
  }
  throw e;
}

Prevention

When it happens

Trigger: `dagger -m github.com/org/repo/not/a/real/dir` (or any misspelled subpath) — the subpath string is non-empty and core.StatFSExists reports it absent in the loaded git tree.

Common situations: Typo in the -m path; path exists on another branch/tag than the one resolved; path renamed or deleted at the pinned ref; using a directory that only exists locally but not in the repo.

Related errors


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