{"record":{"id":"b828b74225fc207d","repo":"anomalyco/sst","slug":"failed-to-create-output-directory-w-b828b7","errorCode":null,"errorMessage":"failed to create output directory: %w","messagePattern":"failed to create output directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/rust/rust.go","lineNumber":147,"sourceCode":"\t}\n\n\t// if binary name is not specified, use the package name\n\tname := cargotoml.Package.Name\n\tif len(parts) >= 2 {\n\t\tname = parts[len(parts)-1]\n\t}\n\tbinary := filepath.Join(root, \"target\",\n\t\tmap[bool]string{\n\t\t\ttrue:  filepath.Join(\"debug\", name),\n\t\t\tfalse: filepath.Join(\"lambda\", name, \"bootstrap\"),\n\t\t}[input.Dev],\n\t)\n\tout := filepath.Join(input.Out(), \"bootstrap\")\n\n\tr.directories[input.FunctionID], _ = filepath.Abs(root)\n\n\tif err := os.MkdirAll(filepath.Dir(out), 0755); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create output directory: %w\", err)\n\t}\n\n\tsource, err := os.Open(binary)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open source binary: %w\", err)\n\t}\n\tdefer source.Close()\n\n\tdestination, err := os.Create(out)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create destination file: %w\", err)\n\t}\n\tdefer destination.Close()\n\n\tif _, err := io.Copy(destination, source); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to copy binary: %w\", err)\n\t}\n","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/rust/rust.go#L129-L165","documentation":"Rust runtime Build creates the output directory (the parent of <bundle>/bootstrap) via os.MkdirAll and wraps failures with this message. It fails when the directory cannot be created — missing ancestor that can't be created, permission denied, or the path exists as a non-directory. The rust build then copies the compiled binary into this location.","triggerScenarios":"os.MkdirAll(filepath.Dir(out), 0755) errors: output root (.sst output path) is read-only or owned by another user, a file exists where a directory is expected, or the path is too long/invalid.","commonSituations":"Running deploy as non-root inside a container whose output volume is root-owned; a corrupted .sst directory containing a file named like the expected function output dir; restricted sandbox (CI runner) denying writes to the project directory.","solutions":["Check permissions/ownership of the .sst output directory and create it writable (chown/chmod)","Remove any file conflicting with the expected output directory path","Run the deploy as a user with write access to the project root","Inspect the wrapped os error text for the precise cause (permission denied vs not a directory)"],"exampleFix":"// before\nsst deploy run as root, output owned by non-root\n// after\nsudo chown -R $(whoami) .sst && bun run build:cli && sst deploy","handlingStrategy":"validation","validationCode":"const out = path.join(projectRoot, \".sst\", \"dist\")\nfs.mkdirSync(out, { recursive: true })\nfs.accessSync(out, fs.constants.W_OK) // throws early if not writable","typeGuard":null,"tryCatchPattern":"if err := sstDeploy(); err != nil {\n\tif strings.Contains(err.Error(), \"failed to create output directory\") {\n\t\t// chown/chmod the .sst output dir or clear a conflicting file, then retry\n\t}\n}","preventionTips":["Pre-create .sst output dirs writable by the deploy user","Don't run deploys as root then switch to a non-root user (or chown -R afterwards)","Keep path lengths under filesystem limits","Check CI sandboxes grant write access to the project directory"],"tags":["go","rust","filesystem","build"],"backgroundTag":"mkdir-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}