dagger/dagger · error

evaluate base selector: %w

Error message

evaluate base selector: %w

What it means

In withGitMergeWorkspace (core/changeset.go:1636), this wraps failure of base.Self().Dir.GetOrEval — resolving the base directory's subpath selector (the path within the directory the merge should operate on). If the selector cannot be evaluated (invalid path, wrong accessor state), the engine cannot locate the working directory inside the snapshot and returns 'evaluate base selector:'.

Source

Thrown at core/changeset.go:1636

// withGitMergeWorkspace sets up a workspace for git merge operations, runs the provided
// function, then commits and returns the resulting directory.
func withGitMergeWorkspace(ctx context.Context, base dagql.ObjectResult[*Directory], description string, fn func(ws *gitMergeWorkspace) error) (*Directory, error) {
	cache, err := dagql.EngineCache(ctx)
	if err != nil {
		return nil, err
	}
	if err := cache.Evaluate(ctx, base); err != nil {
		return nil, fmt.Errorf("evaluate base: %w", err)
	}

	baseRef, err := base.Self().Snapshot.GetOrEval(ctx, base.Result)
	if err != nil {
		return nil, fmt.Errorf("evaluate base: %w", err)
	}
	baseSelector, err := base.Self().Dir.GetOrEval(ctx, base.Result)
	if err != nil {
		return nil, fmt.Errorf("evaluate base selector: %w", err)
	}

	query, err := CurrentQuery(ctx)
	if err != nil {
		return nil, err
	}

	newRef, err := query.SnapshotManager().New(ctx, baseRef,
		bkcache.WithRecordType(bkclient.UsageRecordTypeRegular),
		bkcache.WithDescription(description))
	if err != nil {
		return nil, err
	}

	err = MountRef(ctx, newRef, func(root string, _ *mount.Mount) error {
		workDir, err := containerdfs.RootPath(root, baseSelector)
		if err != nil {
			return err

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Check the subpath argument passed to .Directory()/directory selection — confirm it exists in the base directory (e.g. via `dagger query` or directory.entries).
  2. Evaluate the base directory and its selected subpath separately before the merge to reproduce/see the underlying error.
  3. Fix the upstream pipeline producing the base directory if the selector fails because content is missing.
  4. Upgrade the Dagger CLI/engine to matching versions if this appears after a version change.

Example fix

// before
dir := client.Directory().Directory("src") // path may not exist
merged := dir.WithChangeset(...)

// after
entries, _ := client.Directory().Entries()
// verify "src" exists in entries before selecting
dir := client.Directory().Directory("src")
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the selected subpath exists before merging
entries, err := baseDir.Entries(ctx)
if err != nil {
    return err
}
if !slices.Contains(entries, "src") {
    return fmt.Errorf("subpath %q missing from base directory", "src")
}

Type guard

func isSelectorErr(err error) bool {
    return err != nil && strings.Contains(err.Error(), "evaluate base selector:")
}

Try / catch

merged, err := mergeInto(base.Subdir("src"), cs)
if err != nil && isSelectorErr(err) {
    return fmt.Errorf("check the subpath passed to .Directory(): %w", err)
}

Prevention

When it happens

Trigger: Passing a Directory whose Dir subpath accessor fails to evaluate into a merge: typically a .Directory(subpath) selection on a nonexistent path, or an accessor that was never set/evaluated before the merge call.

Common situations: Typo or wrong subpath passed to .Directory(); operating on a directory derived from a failed build; engine version mismatch where accessor state differs.

Related errors


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