{"record":{"id":"dd37717be511beb7","repo":"pulumi/pulumi","slug":"creating-temporary-directory-for-template-w","errorCode":null,"errorMessage":"creating temporary directory for template: %w","messagePattern":"creating temporary directory for template: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/project/newcmd/new.go","lineNumber":211,"sourceCode":"\tif args.offline {\n\t\tscope = cmdTemplates.ScopeLocal\n\t}\n\ttemplateSource := cmdTemplates.New(ctx,\n\t\targs.templateNameOrURL, scope, cmdTemplates.TemplateKindPulumiProject, env.Global())\n\tdefer contract.IgnoreClose(templateSource)\n\n\tcmdTemplate, err := resolveTemplate(templateSource, args, opts, args.selectOne)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar template cmdTemplates.ProjectTemplate\n\tif cmdTemplate == nil {\n\t\t// Template might be nil if we're running in non-interactive mode and didn't pass a template to choose. In\n\t\t// that case we'll write a minimal Pulumi.yaml.\n\t\ttemp, err := os.MkdirTemp(\"\", \"pulumi-new\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"creating temporary directory for template: %w\", err)\n\t\t}\n\t\t// Write the minimal template to the temp directory\n\t\terr = os.WriteFile(filepath.Join(temp, \"Pulumi.yaml\"), []byte(`name: ${PROJECT}`), 0o600)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"writing minimal Pulumi.yaml: %w\", err)\n\t\t}\n\n\t\ttemplate = cmdTemplates.ProjectTemplate{\n\t\t\tDir:         temp,\n\t\t\tProjectName: \"${PROJECT}\",\n\t\t}\n\t} else {\n\t\ttemplate, err = cmdTemplate.Download(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/project/newcmd/new.go#L193-L229","documentation":"Thrown when `pulumi new` runs non-interactively without a template, so it creates a temporary directory (os.MkdirTemp) to hold a minimal Pulumi.yaml, and that call fails. This typically indicates the OS temp directory is missing, unwritable, or TMPDIR points somewhere invalid.","triggerScenarios":"Running `pulumi new --yes` (non-interactive) with no template argument, when os.MkdirTemp(\"\", \"pulumi-new\") fails due to a bad TMPDIR, full disk, or missing /tmp.","commonSituations":"TMPDIR set to a non-existent path in CI; read-only or full /tmp in a container; sandboxed environment blocking temp directory creation.","solutions":["Verify TMPDIR (or /tmp) exists and is writable: `ls -ld /tmp; touch /tmp/probe`","Fix the TMPDIR environment variable to a valid writable path and rerun","Free disk space if the filesystem is full","Pass an explicit template (`pulumi new typescript`) so the temp-dir fallback is not needed"],"exampleFix":"// before\nTMPDIR=/nonexistent pulumi new --yes\n// after\nTMPDIR=/tmp pulumi new --yes","handlingStrategy":"validation","validationCode":"test -d \"${TMPDIR:-/tmp}\" && touch \"${TMPDIR:-/tmp}/.pulumi-probe\" || export TMPDIR=/tmp","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep TMPDIR pointed at an existing writable directory","Monitor disk space on the temp filesystem","Pass an explicit template in non-interactive runs to avoid the temp fallback"],"tags":["cli","filesystem","temp-directory","tmpdir"],"backgroundTag":"temp-directory-creation-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}