podman-container-tools/podman · error
invalid value for XDG_RUNTIME_DIR: %m
Error message
invalid value for XDG_RUNTIME_DIR: %m
What it means
On the shortcut path the preamble formats '$XDG_RUNTIME_DIR/libpod/tmp/ns_handles' into a char path[PATH_MAX] (pkg/rootless/rootless_linux.c:842-847). If the formatted length reaches PATH_MAX, errno is set to ENAMETOOLONG and the message is printed (without a trailing newline) before exit. Since XDG_RUNTIME_DIR was already validated as set and non-empty, this means its value is absurdly long (~4000+ characters).
Source
Thrown at pkg/rootless/rootless_linux.c:845
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. */
if (errno == ESTALE)
return;
/* Fall back to pause.pid if:
- ENOENT ns_handles file doesn't exist
- EOPNOTSUPP kernel doesn't support open_by_handle_at
- ENOSYS syscall not available
- EPERM (could be seccomp when running in a container)
*/
if (errno != ENOENT && errno != EOPNOTSUPP && errno != ENOSYS && errno != EPERM)
{View on GitHub (pinned to a2409076ef)
Solutions
- Inspect the value: 'echo ${#XDG_RUNTIME_DIR}' - it should be small (e.g. /run/user/1000)
- Fix the exporting script/config to the standard value: export XDG_RUNTIME_DIR=/run/user/$(id -u)
- Log out and back in so systemd sets the variable correctly for the session
- If a legitimate workflow needs long paths, report upstream - PATH_MAX limits apply
Example fix
# before
export XDG_RUNTIME_DIR="/tmp/$(printf 'a%.0s' {1..4200})"
podman ps # invalid value for XDG_RUNTIME_DIR: File name too long
# after
export XDG_RUNTIME_DIR=/run/user/$(id -u)
podman ps
Defensive patterns
Strategy: validation
Validate before calling
# Reject an over-long XDG_RUNTIME_DIR before podman builds paths from it
if [ -n "${XDG_RUNTIME_DIR:-}" ] && [ "${#XDG_RUNTIME_DIR}" -gt 3800 ]; then
echo "XDG_RUNTIME_DIR is too long (${#XDG_RUNTIME_DIR} chars)" >&2
exit 1
fi
Prevention
- Expect XDG_RUNTIME_DIR to be /run/user/<uid>; anything else deserves inspection
- Audit env-generating scripts and CI secret/env injection for corrupted values
When it happens
Trigger: A broken login/profile script, test harness, or fuzzing environment exporting an XDG_RUNTIME_DIR whose length plus the ~25-char suffix reaches 4096; any podman command from that environment as a non-root user.
Common situations: Almost never legitimate - normally XDG_RUNTIME_DIR is /run/user/<uid>. Seen with misconfigured CI env injection, corrupted env files, or deliberate stress tests of environment variables.
Related errors
- internal error: path too long
- cannot retrieve cmd line
- error getting current working directory: %m
- cannot set %s namespace
- fork: %m
AI-assisted analysis of podman-container-tools/podman@a2409076ef (2026-08-15).
Data as JSON: /api/errors/ff3636d71741ddae.
Report an issue: GitHub.