podman-container-tools/podman · error
error getting current working directory: %m
Error message
error getting current working directory: %m
What it means
On the no-re-exec shortcut path (non-root user, XDG_RUNTIME_DIR set, can_use_shortcut(argv) true), the preamble saves the current directory with getcwd(NULL, 0) so it can chdir back after joining the existing user+mount namespaces (pkg/rootless/rootless_linux.c:833-838). This message means getcwd failed - classically ENOENT when the cwd was deleted, EACCES when a parent directory is not searchable, or ENAMETOOLONG - and the process _exits.
Source
Thrown at pkg/rootless/rootless_linux.c:834
{
cleanup_free char *cwd = NULL;
cleanup_close int userns_fd = -1;
cleanup_close int mntns_fd = -1;
cleanup_close int fd = -1;
long pid;
char buf[12];
uid_t uid;
gid_t gid;
char path[PATH_MAX];
char uid_fmt[16];
char gid_fmt[16];
size_t len;
int r;
cwd = getcwd (NULL, 0);
if (cwd == NULL)
{
fprintf (stderr, "error getting current working directory: %m\n");
_exit (EXIT_FAILURE);
}
uid = geteuid ();
gid = getegid ();
len = snprintf (path, PATH_MAX, "%s/libpod/tmp/ns_handles", xdg_runtime_dir);
if (len >= PATH_MAX)
{
errno = ENAMETOOLONG;
fprintf (stderr, "invalid value for XDG_RUNTIME_DIR: %m");
exit (EXIT_FAILURE);
}
if (set_ns_handles (path) == 0)
goto joined;
/* If the handle is stale, give up with the shortcut. */View on GitHub (pinned to a2409076ef)
Solutions
- Change to an existing, accessible directory first: 'cd ~ && podman <cmd>'
- Fix search permissions on the path leading to the cwd if it still exists
- In scripts, always cd to a stable directory before removing the working directory
- For automount issues, ensure the home mount is active before invoking podman
Example fix
# before cd /tmp/build rm -rf /tmp/build podman ps # error getting current working directory: No such file or directory # after WORK=$(pwd); cd ~; rm -rf "$WORK" podman ps
Defensive patterns
Strategy: validation
Validate before calling
# Verify the startup directory exists and is searchable before invoking podman if [ ! -d "$PWD" ] || [ ! -x "$PWD" ]; then cd "$HOME" || exit 1 fi podman "$@"
Prevention
- In scripts, cd to a stable directory before deleting the current one
- Avoid launching podman from just-removed temp/workspace directories
- Ensure automounted home directories are mounted before podman runs
When it happens
Trigger: Invoking podman from a directory that has since been removed (e.g. 'cd /tmp/build && rm -rf /tmp/build && podman ...'); a cwd whose path traverses a directory without execute permission for the user; an automounted home that unmounted; a cwd deeper than PATH_MAX.
Common situations: CI pipelines that delete the workspace directory and then run podman from it; shells sitting in deleted temp dirs; home directories with 0700 perms owned by another user after uid changes; NFS homes after a remount.
Related errors
- cannot chdir to %s: %m
- error getting current working directory: %m\n
- opendir %s: %m
- cannot retrieve cmd line
- invalid value for XDG_RUNTIME_DIR: %m
AI-assisted analysis of podman-container-tools/podman@a2409076ef (2026-08-15).
Data as JSON: /api/errors/ed9886a53854b6d7.
Report an issue: GitHub.