dagger/dagger · error

workspace cwd: %w

Error message

workspace cwd: %w

What it means

workspaceConfigHostPath calls ws.Cwd(ctx) to learn the workspace's current working directory so the config file path can be made workspace-root-relative. If that engine call fails, the error is wrapped with this prefix and returned to all path-dependent workspace operations.

Source

Thrown at internal/cmd/dagger/workspace.go:592

	}
	if err := updated.Export(ctx); err != nil {
		return err
	}
	_, err = fmt.Fprintf(out, "Uninstalled SDK %q from %s\n", name, configPath)
	return err
}

func workspaceConfigHostPath(ctx context.Context, ws *dagger.Workspace) (string, error) {
	configFile, err := ws.ConfigFile(ctx)
	if err != nil {
		return "", fmt.Errorf("workspace config file: %w", err)
	}
	if configFile == "" {
		return "", fmt.Errorf("workspace config file is not selected")
	}
	cwd, err := ws.Cwd(ctx)
	if err != nil {
		return "", fmt.Errorf("workspace cwd: %w", err)
	}
	configFile, err = workspaceConfigRootPathFromCwd(configFile, cwd)
	if err != nil {
		return "", err
	}
	root, err := currentWorkspaceExportPath(ctx, ws)
	if err != nil {
		return "", err
	}
	return filepath.Join(root, filepath.FromSlash(configFile)), nil
}

func workspaceConfigRootPathFromCwd(configFile, cwd string) (string, error) {
	cwd, err := workspaceRelativeCwd(cwd)
	if err != nil {
		return "", err
	}
	configFile = filepath.Clean(filepath.Join(cwd, filepath.FromSlash(configFile)))

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Inspect the wrapped cause for the underlying engine error and fix that (e.g. reconnect the engine).
  2. Re-run the command to get a fresh engine session.
  3. Verify the engine is healthy (`dagger query` with a trivial query) before retrying workspace operations.
Defensive patterns

Strategy: retry

Validate before calling

if _, err := ws.Cwd(ctx); err != nil {
    // engine unreachable or session dead; reconnect before proceeding
    return fmt.Errorf("engine unavailable: %w", err)
}

Try / catch

path, err := workspaceConfigHostPath(ctx, ws)
if err != nil {
    if ctx.Err() != nil { return ctx.Err() }
    return fmt.Errorf("workspace cwd lookup failed; reconnect the engine and retry: %w", err)
}

Prevention

When it happens

Trigger: Any install/uninstall SDK/module or env-write operation where the ws.Cwd() GraphQL call to the engine returns an error (engine failure, session terminated, workspace state unavailable).

Common situations: Engine session crashes mid-command, network/transport failure to the engine, or running against a remote engine where workspace cwd state cannot be fetched.

Related errors


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