{"record":{"id":"fd6d0a5bedbab179","repo":"podman-container-tools/podman","slug":"cannot-chdir-to-s-m","errorCode":null,"errorMessage":"cannot chdir to %s: %m\n","messagePattern":"cannot chdir to (.+?): %m\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rootless/rootless_linux.c","lineNumber":938,"sourceCode":"      setenv (\"_CONTAINERS_ROOTLESS_GID\", gid_fmt, 1);\n\n      /* We are in the user+mount namespace, these errors are not recoverable.  */\n\n      if (syscall_setresgid (0, 0, 0) < 0)\n        {\n          fprintf (stderr, \"cannot setresgid: %m\\n\");\n          _exit (EXIT_FAILURE);\n        }\n\n      if (syscall_setresuid (0, 0, 0) < 0)\n        {\n          fprintf (stderr, \"cannot setresuid: %m\\n\");\n          _exit (EXIT_FAILURE);\n        }\n\n      if (chdir (cwd) < 0)\n        {\n          fprintf (stderr, \"cannot chdir to %s: %m\\n\", cwd);\n          _exit (EXIT_FAILURE);\n        }\n\n      rootless_uid_init = uid;\n      rootless_gid_init = gid;\n    }\n}\n\nstatic int\nsyscall_clone (unsigned long flags, void *child_stack)\n{\n#if defined(__s390__) || defined(__CRIS__)\n  return (int) syscall (__NR_clone, child_stack, flags);\n#else\n  return (int) syscall (__NR_clone, flags, child_stack);\n#endif\n}\n","sourceCodeStart":920,"sourceCodeEnd":956,"githubUrl":"https://github.com/podman-container-tools/podman/blob/a2409076ef2fef60ad9ac046375dedc7d9410ef4/pkg/rootless/rootless_linux.c#L920-L956","documentation":"On the joined-namespaces shortcut path the preamble saved the cwd before joining, then after setresgid/setresuid(0,0,0) does chdir(cwd) to restore the working directory (pkg/rootless/rootless_linux.c:936-941). This message means that chdir failed in the joined user+mount namespace - commonly ENOENT (the directory was removed between getcwd and chdir), EACCES (the path is not searchable by the identity now in force, since uid 0 inside the userns maps to the original user), or a mount that is not visible in the joined mount namespace. The process _exits.","triggerScenarios":"The startup directory is deleted concurrently while podman joins the shared namespaces; the path to the cwd traverses directories whose permissions changed; the cwd sits on a mount (e.g. a FUSE mount with restrictive allow_other/uid settings) that is not accessible from the joined mount namespace.","commonSituations":"CI scripts removing the workspace then invoking podman; running podman from an automounted or FUSE directory; concurrent permission changes on home directory trees.","solutions":["Re-run the command from a stable, accessible directory such as $HOME","If the directory was deleted, recreate it or change out of it before invoking podman","For FUSE mounts, ensure they are mounted with permissions allowing the podman process (allow_other, correct uid)","Report upstream if a permanently existing directory on a normal filesystem still triggers it"],"exampleFix":"# before\ncd /tmp/job && rm -rf /tmp/job\npodman ps   # cannot chdir to /tmp/job: No such file or directory\n\n# after\nWORK=$(pwd); cd \"$HOME\"; rm -rf \"$WORK\"\npodman ps\n","handlingStrategy":"validation","validationCode":"# Use a directory that will exist and stay accessible across the namespace join\ncase \"$PWD\" in /tmp/*|/var/tmp/*) cd \"$HOME\" || exit 1;; esac\npodman \"$@\"\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Invoke podman from stable directories such as $HOME","Avoid FUSE-mounted or automounted directories as the startup cwd for rootless podman","Do not delete the startup directory while a podman command is launching"],"tags":["filesystem","cwd","namespace","rootless","permissions"],"backgroundTag":null,"analyzedSha":"a2409076ef2fef60ad9ac046375dedc7d9410ef4","analyzedAt":"2026-08-15T15:57:05.625Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}