podman-container-tools/podman · error

error getting current working directory: %m\n

Error message

error getting current working directory: %m\n

What it means

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.

Source

Thrown at pkg/rootless/rootless_linux.c:1301

}

int
reexec_in_user_namespace (int ready, char *state_dir)
{
  cleanup_free char **argv = NULL;
  cleanup_free char *argv0 = NULL;
  cleanup_free char *cwd = NULL;
  sigset_t sigset, oldsigset;
  int ret;
  pid_t pid;
  char b;
  char uid[16];
  char gid[16];

  cwd = getcwd (NULL, 0);
  if (cwd == NULL)
    {
      fprintf (stderr, "error getting current working directory: %m\n");
      _exit (EXIT_FAILURE);
    }

  sprintf (uid, "%d", geteuid ());
  sprintf (gid, "%d", getegid ());

  pid = syscall_clone (CLONE_NEWUSER|CLONE_NEWNS|SIGCHLD, NULL);
  if (pid < 0)
    {
      fprintf (stderr, "cannot clone: %m\n");
      check_proc_sys_userns_file (_max_user_namespaces);
      check_proc_sys_userns_file (_unprivileged_user_namespaces);
    }
  if (pid)
    {
      if (do_socket_activation)
        {
          long num_fds;

View on GitHub (pinned to a2409076ef)

Solutions

  1. cd to a stable existing directory (e.g. $HOME) and re-run podman
  2. Set systemd WorkingDirectory= to a durable path and restart the unit
  3. Repair/remount the filesystem that hosted the deleted or stale cwd
Defensive patterns

Strategy: validation

Validate before calling

cd "${HOME:-/}" || exit 1    # ensure a valid cwd before any rootless podman call
pwd >/dev/null || exit 1

Prevention

When it happens

Trigger: 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.

Common situations: CI cleaning its workspace and then invoking podman; services with WorkingDirectory pointing at removed directories; NFS/automount home directories that went stale.

Related errors


AI-assisted analysis of podman-container-tools/podman@a2409076ef (2026-08-15). Data as JSON: /api/errors/cef4c3bf084a3d49. Report an issue: GitHub.