dagger/dagger · warning

ErrGitNoRepo

ErrGitNoRepo

Error message

not a git repository

What it means

Sentinel error returned by translateError when git reports the target path is not a git repository. Wrappers like MaterializeHostGitCheckout, GitCheckoutState, PackGitCheckout propagate it so callers can treat 'no git context' as an expected, non-fatal condition.

Source

Thrown at util/gitutil/error.go:11

package gitutil

import (
	"context"
	"errors"
	"strings"
)

var (
	ErrGitAuthFailed       = errors.New("git authentication failed")
	ErrGitNoRepo           = errors.New("not a git repository")
	ErrShallowNotSupported = errors.New("shallow clone not supported")
	// ErrSHAFetchUnsupported is a normalized signal that retry-by-named-ref may succeed.
	ErrSHAFetchUnsupported = errors.New("sha fetch unsupported by remote")
)

func translateError(err error, stderr string) error {
	if err == nil {
		return nil
	}

	if errors.Is(err, context.DeadlineExceeded) {
		return context.DeadlineExceeded
	}
	if errors.Is(err, context.Canceled) {
		return context.Canceled
	}

	stderr = strings.ToLower(stderr)

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Initialize git in the directory (git init) or run the command from inside the actual repository
  2. Treat errors.Is(err, gitutil.ErrGitNoRepo) as 'no git context' and proceed without provenance (as core/git_hostdir.go returns ErrNoGitContext)
  3. Check you are in the intended repo root rather than a subdirectory or copied tree
  4. Copy the .git directory or use a proper checkout when materializing host directories

Example fix

// before
state, err := bk.GitCheckoutState(ctx, hostPath)
if err != nil {
	return err
}
// after
state, err := bk.GitCheckoutState(ctx, hostPath)
if err != nil {
	if errors.Is(err, gitutil.ErrGitNoRepo) {
		return tree, ErrNoGitContext
	}
	return err
}
Defensive patterns

Strategy: type-guard

Validate before calling

if _, err := os.Stat(filepath.Join(dir, ".git")); err != nil {
	// not a git repo — skip git-based provenance
}

Type guard

func isNoRepo(err error) bool {
	return errors.Is(err, gitutil.ErrGitNoRepo)
}

Try / catch

state, err := bk.GitCheckoutState(ctx, hostPath)
if err != nil {
	if errors.Is(err, gitutil.ErrGitNoRepo) {
		return tree, ErrNoGitContext
	}
	return err
}

Prevention

When it happens

Trigger: Running git commands (rev-parse, status, packing) in a directory without a .git dir; GitCheckoutState on a plain host directory; engine client maps git.NOT_A_REPO result errors onto this sentinel.

Common situations: Running dagger in a plain folder instead of a git checkout; submodules or vendored dirs outside the repo; user expects git-based provenance but the context isn't a repo.

Related errors


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