{"record":{"id":"d914fdae71ca6034","repo":"dagger/dagger","slug":"failed-to-lstat-s-w-d914fd","errorCode":null,"errorMessage":"failed to lstat %s: %w","messagePattern":"failed to lstat (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/engineutil/cacerts/distros.go","lineNumber":261,"sourceCode":"\t\ttargetPath := target\n\t\tif !filepath.IsAbs(targetPath) {\n\t\t\ttargetPath = filepath.Join(filepath.Dir(d.bundlePath), targetPath)\n\t\t}\n\t\tcontent, err := d.ctrFS.ReadFile(targetPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to read symlink target %s for %s: %w\", targetPath, d.bundlePath, err)\n\t\t}\n\t\tif err := d.ctrFS.Remove(d.bundlePath); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to remove symlink %s: %w\", d.bundlePath, err)\n\t\t}\n\t\tif err := d.ctrFS.WriteFile(d.bundlePath, content, 0o644); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to materialize %s: %w\", d.bundlePath, err)\n\t\t}\n\t\td.origSymlinkTarget = target\n\tcase errors.Is(err, os.ErrNotExist):\n\t\t// No bundle yet — commonInstaller will create one.\n\tcase err != nil:\n\t\treturn fmt.Errorf(\"failed to lstat %s: %w\", d.bundlePath, err)\n\t}\n\treturn d.commonInstaller.Install(ctx)\n}\n\nfunc (d *nixosLike) Uninstall(ctx context.Context) error {\n\t// Run commonInstaller's uninstall regardless of whether we swapped the\n\t// symlink. Capture its error and keep going — the symlink restore below\n\t// is the only thing that frees up the materialized bundle (which may still\n\t// contain the cert if commonInstaller.Uninstall failed).\n\trerr := d.commonInstaller.Uninstall(ctx)\n\tif d.origSymlinkTarget == \"\" {\n\t\treturn rerr\n\t}\n\ttarget := d.origSymlinkTarget\n\td.origSymlinkTarget = \"\"\n\tif err := d.ctrFS.Remove(d.bundlePath); err != nil && !errors.Is(err, os.ErrNotExist) {\n\t\trerr = errors.Join(rerr, fmt.Errorf(\"failed to remove materialized bundle %s: %w\", d.bundlePath, err))\n\t}","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/engineutil/cacerts/distros.go#L243-L279","documentation":"nixosLike.Install calls ctrFS.Lstat on the CA bundle path to determine whether it's a symlink, a missing file, or something else. ErrNotExist means the bundle doesn't exist yet (commonInstaller will create it) and a symlink triggers the swap logic; any other Lstat error aborts installation with this wrapped error.","triggerScenarios":"ctrFS.Lstat(d.bundlePath) returns an unexpected error (EACCES, EIO, ENOTDIR, etc.) during nixosLike.Install — e.g. /etc/ssl/certs doesn't exist as a directory or is unreadable.","commonSituations":"Minimal Nix/distroless images missing /etc/ssl/certs as a traversable directory; permission-restricted rootless containers; I/O errors on damaged snapshots.","solutions":["Check the wrapped cause: if ENOTDIR/ENOENT on the parent, create the directory or fix SSL_CERT_FILE to a valid absolute path","Ensure /etc/ssl/certs exists and is traversable in the image","Fix permissions so the engine process can stat the path","If SSL_CERT_FILE points somewhere invalid, unset it so the default bundle path is used"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(\"/etc/ssl/certs\"); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\"/etc/ssl/certs must be a traversable directory in the image\")\n}\nif v, ok := os.LookupEnv(\"SSL_CERT_FILE\"); ok && !filepath.IsAbs(v) {\n    return fmt.Errorf(\"SSL_CERT_FILE must be an absolute path, got %q\", v)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure /etc/ssl/certs exists as a directory in Nix/distroless images","Only set SSL_CERT_FILE to valid absolute paths","Check snapshot health if EIO errors appear","Verify permissions allow stat on the bundle path for rootless runs"],"tags":["filesystem","lstat","ca-certificates","nixos","container"],"backgroundTag":"path-stat-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"}