dagger/dagger · error

resolve workspace %q: %w

Error message

resolve workspace %q: %w

What it means

Wraps a pathutil.Abs failure in sdkInitConfigSearchRoot when converting a user-supplied workspace reference to an absolute path. This only happens for non-remote (local) workspace refs whose path cannot be made absolute.

Source

Thrown at internal/cmd/dagger/sdk_init_dynamic.go:321

	root, ok, err := sdkInitConfigSearchRoot()
	if err != nil {
		return nil, "", err
	}
	if !ok {
		return nil, "", nil
	}

	return readWorkspaceConfigForSDKInitRegistrationFrom(root)
}

func sdkInitConfigSearchRoot() (string, bool, error) {
	if workspaceRef != "" {
		if isObviouslyRemoteWorkspaceRef(workspaceRef) {
			return "", false, nil
		}
		abs, err := pathutil.Abs(workspaceRef)
		if err != nil {
			return "", false, fmt.Errorf("resolve workspace %q: %w", workspaceRef, err)
		}
		return abs, true, nil
	}

	cwd, err := os.Getwd()
	if err != nil {
		return "", false, fmt.Errorf("getwd: %w", err)
	}
	return cwd, true, nil
}

func readWorkspaceConfigForSDKInitRegistrationFrom(start string) (*workspace.Config, string, error) {
	dir := start
	for {
		cfgPath := filepath.Join(dir, workspace.ConfigFileName)
		if _, err := os.Stat(cfgPath); err == nil {
			data, err := os.ReadFile(cfgPath)
			if err != nil {

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Pass a valid local directory path or omit the flag to use the current working directory
  2. Use a remote ref (e.g. git URL) if you meant a remote workspace — those skip this path resolution
  3. Quote the path in your shell to avoid it being mangled

Example fix

// before
$ dagger sdk init py --workspace ""
// after
$ dagger sdk init py --workspace /path/to/workspace
Defensive patterns

Strategy: validation

Validate before calling

[ -d "$WORKSPACE_REF" ] || [ "$WORKSPACE_REF" =~ ^(https?|git|ssh):// ] || echo "--workspace must be a valid local dir or remote ref"

Try / catch

if err != nil && strings.HasPrefix(err.Error(), "resolve workspace") { return fmt.Errorf("bad --workspace value: %w", err) }

Prevention

When it happens

Trigger: Passing `--workspace <ref>` (or similar) with a local path string that pathutil.Abs rejects — typically an unresolvable/empty-ish malformed path that isn't caught by the remote-ref check.

Common situations: Malformed --workspace flag value; unusual path characters; environment where path resolution fails.

Related errors


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