How to fix dpkg: warning: PATH is not set in APT

APTBEGINNERMEDIUMUpdated Dec 29, 2025ยท 215 views

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.

Quick fix

Fixes dpkg: warning: PATH is not set

su -
  1. Use 'su -' instead of 'su' to switch to root
  2. Verify PATH contains system directories
  3. Manually set PATH if necessary
  4. Use 'sudo -i' as an alternative to 'su -'
apt โ€” error
su -
dpkg: warning: PATH is not set

What this error means

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.

Typical symptoms

  • dpkg fails to install or configure packages when run as root
  • Error mentions 'ldconfig', 'start-stop-daemon', or 'update-rc.d' not found
  • Installation works with sudo but fails with su
  • Container or build process fails during package installation

Common causes

  1. Using 'su' instead of 'su -' when switching to root, leaving user PATH intact
  2. Running dpkg in a shell environment without proper PATH initialization
  3. Manually unsetting or incorrectly configuring the PATH environment variable
  4. Entering a restricted shell or SSH session without a login shell initialization
  5. Using Docker or containers without proper environment setup

How to fix "dpkg: warning: PATH is not set"

1Use 'su -' instead of 'su' to switch to root

When switching to the root user, always use the dash flag:

bash
su -

Instead of just:

bash
su

The 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.

2Verify PATH contains system directories

Check if your PATH includes the necessary system directories:

bash
echo $PATH

You should see output similar to:

bash
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

If this is missing or incomplete, proceed to the next step.

3Manually set PATH if necessary

If PATH is not set correctly, export the full path before running dpkg:

bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Then run your dpkg command:

bash
dpkg -i package.deb
4Use 'sudo -i' as an alternative to 'su -'

If you prefer not to use 'su -', you can use sudo with the -i flag:

bash
sudo -i

This also loads the target user's login shell and sets up the environment correctly. You can then run dpkg commands without PATH issues.

Advanced notes

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.

Frequently asked questions

What does "dpkg: warning: PATH is not set" mean?
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.
How do I fix "dpkg: warning: PATH is not set"?
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.
What causes "dpkg: warning: PATH is not set"?
Using 'su' instead of 'su -' when switching to root, leaving user PATH intact Running dpkg in a shell environment without proper PATH initialization Manually unsetting or incorrectly configuring the PATH environment variable
Is the "dpkg: warning: PATH is not set" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading