{"record":{"id":"1f8b520e5413ae2a","repo":"dagger/dagger","slug":"failed-to-create-temp-file","errorCode":null,"errorMessage":"failed to create temp file","messagePattern":"failed to create temp file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/snapshots/localmounter_linux.go","lineNumber":70,"sourceCode":"\t\t}\n\t\tif !fi.IsDir() {\n\t\t\tisFile = true\n\t\t}\n\t}\n\n\tlm.overlayIncompatDirs = fsdiff.VolatileIncompatDirs(lm.mounts)\n\n\tdest, err := os.MkdirTemp(\"\", \"dagger-mount\")\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"failed to create temp dir\")\n\t}\n\tlm.tmpDir = dest\n\n\tif isFile {\n\t\tdest = filepath.Join(dest, \"file\")\n\t\tif err := os.WriteFile(dest, []byte{}, 0o644); err != nil {\n\t\t\tos.RemoveAll(lm.tmpDir)\n\t\t\treturn \"\", errors.Wrap(err, \"failed to create temp file\")\n\t\t}\n\t}\n\n\tif err := mount.All(lm.mounts, dest); err != nil {\n\t\tos.RemoveAll(lm.tmpDir)\n\t\treturn \"\", errors.Wrapf(err, \"failed to mount %s: %+v\", dest, lm.mounts)\n\t}\n\tlm.target = dest\n\treturn dest, nil\n}\n\nfunc (lm *localMounter) Unmount() error {\n\tlm.mu.Lock()\n\tdefer lm.mu.Unlock()\n\n\tif lm.target != \"\" {\n\t\tif err := mount.Unmount(lm.target, 0); err != nil {\n\t\t\treturn err","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/snapshots/localmounter_linux.go#L52-L88","documentation":"When the local mounter wraps a single file (isFile), it writes an empty placeholder file inside the freshly created temp dir so the file can be bind-mounted; failure to create that file aborts Mount and cleans up the temp dir. The cause is the wrapped os.WriteFile error.","triggerScenarios":"Mounting a single host file where the temp dir's filesystem rejects the write: ENOSPC, read-only tmpfs, or permission/ACL restrictions on the dagger-mount temp directory.","commonSituations":"Disk-full /tmp; containers with read-only rootfs; security policies (SELinux) denying file creation in /tmp.","solutions":["Free space on the filesystem backing TMPDIR","Ensure TMPDIR is writable and not read-only mounted","Check LSM/permission policies for the process user","Inspect the wrapped os.WriteFile error for the exact errno"],"exampleFix":"// before\nTMPDIR=/readonly-tmp dagger ...\n// after\nexport TMPDIR=$(mktemp -d)  # writable location\ndagger ...","handlingStrategy":"validation","validationCode":"probe, err := os.CreateTemp(os.TempDir(), \"dagger-probe\")\nif err != nil {\n    return fmt.Errorf(\"cannot write to temp dir: %w\", err)\n}\nprobe.Close(); os.Remove(probe.Name())","typeGuard":null,"tryCatchPattern":"dir, err := lm.Mount()\nif err != nil && strings.Contains(err.Error(), \"failed to create temp file\") {\n    return fmt.Errorf(\"temp filesystem not writable or full: %w\", err)\n}","preventionTips":["Ensure the temp filesystem has free space for single-file mounts","Avoid read-only tmpfs for TMPDIR","Check LSM policies allow the engine user to create files in /tmp"],"tags":["linux","temp-file","filesystem"],"backgroundTag":"temp-dir-creation-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}