pulumi/pulumi · error
failed to create directory for SDK: %w
Error message
failed to create directory for SDK: %w
What it means
When `pulumi package add`/`gen-sdk` generates a language SDK, it first creates the destination directory `<project>/sdks` with os.MkdirAll. If the OS cannot create that directory tree, the command wraps the OS error with this message and returns it alongside any diagnostics. It is a filesystem/permission failure, not a schema or codegen problem.
Source
Thrown at pkg/cmd/pulumi/packages/packages.go:129
diags, err := GenSDK(
pctx.Request(),
registry,
language,
tempOut,
pkg,
"", /*overlays*/
local, /*local*/
)
if err != nil {
return nil, nil, diags, fmt.Errorf("failed to generate SDK: %w", err)
}
out := filepath.Join(root, "sdks")
fmt.Fprintf(stdout, "Successfully generated an SDK for the %s package at %s\n", pkg.Name, out)
err = os.MkdirAll(out, 0o755)
if err != nil {
return nil, nil, diags, fmt.Errorf("failed to create directory for SDK: %w", err)
}
outName := pkg.Name
if pkg.Namespace != "" {
outName = pkg.Namespace + "-" + outName
}
out = filepath.Join(out, outName)
// If directory already exists, remove it completely before copying new files
if _, err := os.Stat(out); err == nil {
if err := os.RemoveAll(out); err != nil {
return nil, nil, diags, fmt.Errorf("failed to clean existing SDK directory: %w", err)
}
}
err = fsutil.CopyFile(out, filepath.Join(tempOut, language), nil)
if err != nil {
return nil, nil, diags, fmt.Errorf("failed to move SDK to project: %w", err)View on GitHub (pinned to 793f7b2e16)
Solutions
- Check write permissions on the project root: `ls -ld .` and fix with chmod/chown or move the project.
- Verify no file named `sdks` exists where a directory is needed (`rm` or rename it).
- Check available disk space with `df -h` and free space if full.
- If in a container, ensure the volume is mounted read-write (`docker run -v dir:/work` without :ro).
Example fix
// before (shell) pulumi package add ../my-provider // error: failed to create directory for SDK: mkdir .: read-only file system // after (shell) chmod u+w . && pulumi package add ../my-provider
Defensive patterns
Strategy: validation
Validate before calling
// shell pre-check before running the CLI
if [ ! -w . ]; then echo "project dir not writable"; exit 1; fi
[ ! -e sdks ] || [ -d sdks ] || { echo "sdks exists but is a file"; exit 1; } Prevention
- Ensure the project directory is writable by the invoking user before codegen.
- Never mount project volumes read-only when running `pulumi package add`.
- Avoid creating a file named `sdks` in project root.
When it happens
Trigger: os.MkdirAll(filepath.Join(root, "sdks"), 0o755) returns an error: e.g. the project root is read-only, a parent path component is missing or is a file, the disk is full, or the process lacks write permission on the project directory.
Common situations: Running the CLI in a project owned by another user, running inside a container with a read-only mounted volume, project path is actually a file, or a read-only network mount; also on Windows when an antivirus briefly locks the path.
Related errors
- Could not locate an executable pulumi-watch, found %v withou
- removing undecryptable credentials: %w
- backing up existing configuration file: %w
- reading log directory %s: %w
- opening log file: %w
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/4cae879b442c6d2e.
Report an issue: GitHub.