pulumi/pulumi · error

unable to create %q for generated SDKs: %w

Error message

unable to create %q for generated SDKs: %w

What it means

After generating into a temp dir, the workspace creates the final SDK directory (sdkDir) with os.Mkdir. If mkdir fails for a reason other than already-exists, this error wraps the OS error.

Source

Thrown at pkg/cmd/pulumi/packageworkspace/packageworkspace.go:283

	pkgName := boundSchema.Name
	if boundSchema.Namespace != "" {
		pkgName = boundSchema.Namespace + "-" + pkgName
	}

	sdkDir := filepath.Join(projectDir, "sdks")
	out := filepath.Join(sdkDir, pkgName)

	// Make sure the out directory doesn't exist anymore.
	//
	// [os.RemoveAll] handles the case  where out doesn't exist.
	if err := os.RemoveAll(out); err != nil {
		return workspace.LinkablePackageDescriptor{}, err
	}

	// Now move the temp directory to it's final home.
	if err := os.Mkdir(sdkDir, 0o755); err != nil && !errors.Is(err, os.ErrExist) {
		return workspace.LinkablePackageDescriptor{}, fmt.Errorf("unable to create %q for generated SDKs: %w", sdkDir, err)
	}

	// We copy instead of renaming to be robust to multiple FS partitions or drives.
	//
	// For example https://github.com/pulumi/pulumi/issues/21547.
	if err := fsutil.CopyFile(out, tmpDir, nil); err != nil {
		// If this failed, we still need to clean up tmpDir.
		return workspace.LinkablePackageDescriptor{}, errors.Join(err, os.RemoveAll(tmpDir))
	}

	// We have now generated a SDK, the only thing left to do is link it into the existing project.

	sdkPath, err := filepath.Rel(projectDir, out)
	if err != nil {
		return workspace.LinkablePackageDescriptor{}, err
	}
	desc, err := boundSchema.Descriptor(ctx)
	if err != nil {

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Check write permissions on the project directory and its parent
  2. Remove or rename any file conflicting with the SDK output path (e.g. ./sdk)
  3. Run the command in a writable directory / fix ownership (chown/chmod)
  4. Check for read-only mounts in containers or CI

Example fix

// before
-rw-r--r-- sdk   # a file where the sdk dir should go
// after
rm ./sdk  # or rename it, then re-run pulumi package add
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the SDK output path is creatable before running
if _, err := os.Stat("./sdk"); err == nil {
    // exists: ensure it's a directory and writable
}
if err := os.MkdirAll("./sdk", 0o755); err != nil { /* fix perms/conflicts */ }

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: os.Mkdir(sdkDir, 0o755) fails with e.g. EACCES (no write permission on parent), ENOTDIR (sdkDir path contains a file component), or a path collision where a non-directory exists and errors.Is check doesn't cover it.

Common situations: Read-only project directories (CI checkout with restricted perms); a file named `sdk` already exists in the project; sandboxed/readonly containers.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/01743d17ca4bb2cf. Report an issue: GitHub.