The PATH environment variable is not set when running dpkg. This prevents dpkg from finding essential programs like ldconfig and start-stop-daemon, causing installation failures.
The dpkg package manager requires the PATH environment variable to locate helper programs needed during package installation and configuration. When PATH is not set or doesn't include critical system directories like /usr/sbin and /sbin, dpkg cannot execute these programs and will fail with a warning or error. This typically happens when using 'su' instead of 'su -' to switch to root, or when running dpkg in a shell with an incomplete environment.
When switching to the root user, always use the dash flag:
su -Instead of just:
suThe dash flag ensures that the root user's full login environment is initialized, including the correct PATH variable containing /usr/sbin, /usr/bin, /sbin, and /bin.
Check if your PATH includes the necessary system directories:
echo $PATHYou should see output similar to:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binIf this is missing or incomplete, proceed to the next step.
If PATH is not set correctly, export the full path before running dpkg:
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binThen run your dpkg command:
dpkg -i package.debIf you prefer not to use 'su -', you can use sudo with the -i flag:
sudo -iThis also loads the target user's login shell and sets up the environment correctly. You can then run dpkg commands without PATH issues.
Maintainer scripts in Debian packages should not prepend absolute paths to program names like ldconfig or start-stop-daemon. The Debian policy expects these programs to be found via PATH. If you're seeing this in a container, ensure your Dockerfile or build script uses proper shell initialization (e.g., '/bin/bash -l' instead of '/bin/sh'). For WSL users with ldconfig-specific issues, the ldconfig binary is part of the libc-bin package, not a standalone package.
E: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT