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 errView on GitHub (pinned to 82ba2681db)
Solutions
- Check the subpath argument passed to .Directory()/directory selection — confirm it exists in the base directory (e.g. via `dagger query` or directory.entries).
- Evaluate the base directory and its selected subpath separately before the merge to reproduce/see the underlying error.
- Fix the upstream pipeline producing the base directory if the selector fails because content is missing.
- 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
- Always verify subpaths exist via directory.entries before selecting them
- Avoid string-built paths; use constants or schema-validated paths
- Test the base-directory construction pipeline independently of the merge
- Keep CLI and engine versions aligned to avoid accessor state mismatches
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
- evaluate changeset diff directory: %w
- failed to evaluate changeset diff snapshot: %w
- diff snapshot: %w
- diff path: %w
- evaluate base: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/4ec32e51f2c20260.
Report an issue: GitHub.