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
- Check write permissions on the project directory and its parent
- Remove or rename any file conflicting with the SDK output path (e.g. ./sdk)
- Run the command in a writable directory / fix ownership (chown/chmod)
- 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
- Never commit a file named `sdk` where generated SDKs go
- Run with a writable project directory in CI
- Check container mount permissions before codegen
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
- creating plugin root: %w
- Could not locate an executable pulumi-watch, found %v withou
- removing undecryptable credentials: %w
- creating cache dir: %w
- creating temp file: %w
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/01743d17ca4bb2cf.
Report an issue: GitHub.