{"record":{"id":"cef4c3bf084a3d49","repo":"podman-container-tools/podman","slug":"error-getting-current-working-directory-m-n","errorCode":null,"errorMessage":"error getting current working directory: %m\\n","messagePattern":"error getting current working directory: %m\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rootless/rootless_linux.c","lineNumber":1301,"sourceCode":"}\n\nint\nreexec_in_user_namespace (int ready, char *state_dir)\n{\n  cleanup_free char **argv = NULL;\n  cleanup_free char *argv0 = NULL;\n  cleanup_free char *cwd = NULL;\n  sigset_t sigset, oldsigset;\n  int ret;\n  pid_t pid;\n  char b;\n  char uid[16];\n  char gid[16];\n\n  cwd = getcwd (NULL, 0);\n  if (cwd == NULL)\n    {\n      fprintf (stderr, \"error getting current working directory: %m\\n\");\n      _exit (EXIT_FAILURE);\n    }\n\n  sprintf (uid, \"%d\", geteuid ());\n  sprintf (gid, \"%d\", getegid ());\n\n  pid = syscall_clone (CLONE_NEWUSER|CLONE_NEWNS|SIGCHLD, NULL);\n  if (pid < 0)\n    {\n      fprintf (stderr, \"cannot clone: %m\\n\");\n      check_proc_sys_userns_file (_max_user_namespaces);\n      check_proc_sys_userns_file (_unprivileged_user_namespaces);\n    }\n  if (pid)\n    {\n      if (do_socket_activation)\n        {\n          long num_fds;","sourceCodeStart":1283,"sourceCodeEnd":1319,"githubUrl":"https://github.com/podman-container-tools/podman/blob/a2409076ef2fef60ad9ac046375dedc7d9410ef4/pkg/rootless/rootless_linux.c#L1283-L1319","documentation":"In reexec_in_user_namespace (pkg/rootless/rootless_linux.c:1286, the C helper behind rootless.BecomeRootInUserNS in pkg/rootless/rootless_linux.go), getcwd(NULL, 0) failed at the very start of the rootless re-exec, and the process _exit(EXIT_FAILURE)s with %m errno. The cwd is needed to chdir back inside the freshly created user+mount namespaces. Same syscall failure class as error 42, but on the create-namespace path rather than the join path.","triggerScenarios":"Current directory deleted while podman runs (ENOENT); no search permission on a path component (EACCES); cwd on a dead/automount-expired filesystem (ESTALE/ENOTCONN) — all before the CLONE_NEWUSER at line 1308.","commonSituations":"CI cleaning its workspace and then invoking podman; services with WorkingDirectory pointing at removed directories; NFS/automount home directories that went stale.","solutions":["cd to a stable existing directory (e.g. $HOME) and re-run podman","Set systemd WorkingDirectory= to a durable path and restart the unit","Repair/remount the filesystem that hosted the deleted or stale cwd"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"cd \"${HOME:-/}\" || exit 1    # ensure a valid cwd before any rootless podman call\npwd >/dev/null || exit 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run rootless podman from stable local directories, not deleted build dirs or automounted paths","Set systemd WorkingDirectory= to durable paths for user services","In automation, always `cd \"$HOME\"` (or /tmp) before invoking podman"],"tags":["podman","rootless","userns","filesystem","cwd"],"backgroundTag":null,"analyzedSha":"a2409076ef2fef60ad9ac046375dedc7d9410ef4","analyzedAt":"2026-08-15T15:57:05.625Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}