podman-container-tools/podman · error
cannot chdir to %s: %m
Error message
cannot chdir to %s: %m
What it means
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.
Source
Thrown at pkg/rootless/rootless_linux.c:938
setenv ("_CONTAINERS_ROOTLESS_GID", gid_fmt, 1);
/* We are in the user+mount namespace, these errors are not recoverable. */
if (syscall_setresgid (0, 0, 0) < 0)
{
fprintf (stderr, "cannot setresgid: %m\n");
_exit (EXIT_FAILURE);
}
if (syscall_setresuid (0, 0, 0) < 0)
{
fprintf (stderr, "cannot setresuid: %m\n");
_exit (EXIT_FAILURE);
}
if (chdir (cwd) < 0)
{
fprintf (stderr, "cannot chdir to %s: %m\n", cwd);
_exit (EXIT_FAILURE);
}
rootless_uid_init = uid;
rootless_gid_init = gid;
}
}
static int
syscall_clone (unsigned long flags, void *child_stack)
{
#if defined(__s390__) || defined(__CRIS__)
return (int) syscall (__NR_clone, child_stack, flags);
#else
return (int) syscall (__NR_clone, flags, child_stack);
#endif
}
View on GitHub (pinned to a2409076ef)
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
Example fix
# before cd /tmp/job && rm -rf /tmp/job podman ps # cannot chdir to /tmp/job: No such file or directory # after WORK=$(pwd); cd "$HOME"; rm -rf "$WORK" podman ps
Defensive patterns
Strategy: validation
Validate before calling
# Use a directory that will exist and stay accessible across the namespace join case "$PWD" in /tmp/*|/var/tmp/*) cd "$HOME" || exit 1;; esac podman "$@"
Prevention
- 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
When it happens
Trigger: 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.
Common situations: CI scripts removing the workspace then invoking podman; running podman from an automounted or FUSE directory; concurrent permission changes on home directory trees.
Related errors
- opendir %s: %m
- error getting current working directory: %m
- error getting current working directory: %m\n
- stat %s: %m
- error opening namespace handles: %m
AI-assisted analysis of podman-container-tools/podman@a2409076ef (2026-08-15).
Data as JSON: /api/errors/fd6d0a5bedbab179.
Report an issue: GitHub.