How to fix apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct! in APT
This error occurs when apt-listchanges cannot find a valid locale configuration on your system. Your locale environment variables (LC_* and LANG) are either unset, invalid, or pointing to locales that haven't been generated.
Quick fix
Fixes apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
locale
locale -a- Check your current locale configuration
- Regenerate locales using dpkg-reconfigure
- Or manually enable and generate locales
- For SSH-specific issues, check client configuration
localelocale -aapt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
What this error means
The error means that apt-listchanges (a tool that displays changes for upgraded packages) tried to format output using your system's locale settings but failed. This happens because either no locales are generated on your system, the locale you're using doesn't exist, or your LANG and LC_* environment variables reference a non-existent locale. While the tools still function, the error prevents proper text formatting and makes the upgrade process uncomfortable.
Typical symptoms
- apt-listchanges warning appears during apt update or apt upgrade commands
- Error message shows "Can't set locale; make sure $LC_* and $LANG are correct!"
- Running locale command shows "Cannot set LC_ALL to default locale" errors
- SSH connections to the server produce locale-related warnings
- Perl scripts on the system also complain about locale settings
Common causes
- No locales have been generated on the system (most common on minimal/container installations)
- Environment variables reference a locale that hasn't been installed (e.g., en_US.UTF-8 is referenced but not in /etc/locale.gen)
- Invalid locale codes in LANG or LC_* variables (e.g., en_NL.UTF-8 which doesn't exist)
- SSH client forwards unsupported locales from your local machine to a remote server
- System upgraded without regenerating locale data after locale installation changes
How to fix "apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!"
First, see what locales are currently set and available:
locale
locale -aThe first command shows your current settings. The second lists all available (generated) locales. If LANG and LC_* variables reference locales not in the list from locale -a, that's your problem.
This is the recommended fix on Debian/Ubuntu. Run:
sudo dpkg-reconfigure localesA dialog will appear. Select at least one locale (en_US.UTF-8 is standard) by pressing SPACE to toggle it. Then press ENTER to confirm. In the next screen, select your preferred default locale. The system will generate the selected locales automatically.
If dpkg-reconfigure doesn't work, edit the locale generation file directly:
sudo nano /etc/locale.genUncomment (remove the #) from the locale you want (e.g., en_US.UTF-8 or C.UTF-8). Save the file, then run:
sudo locale-genThen set it as the default:
sudo update-locale LANG=en_US.UTF-8If you're seeing this error only over SSH, your SSH client may be forwarding unsupported locales. Check your SSH config:
grep -i sendenv ~/.ssh/configIf you see SendEnv LANG LC_*, either remove it or make sure your remote system supports the locales your local machine uses. Alternatively, restart SSH on the server:
sudo systemctl restart sshAfter making changes, run apt again:
sudo apt updateThe locale warning should be gone. You can also verify with:
localeYour LANG should now match one of the installed locales from locale -a.
Advanced notes
In container environments (Docker, LXC, Kubernetes), locale generation may require installing the locales package first: apt-get install -y locales. Some minimal images skip this to reduce size. For headless servers where you don't care about locale-specific formatting, you can set LC_ALL=C.UTF-8 to use the minimal locale without generating others, though proper locale generation is preferred. On systems with strict resource constraints, consider installing locales-all instead of configuring individual locales.
Frequently asked questions
- What does "apt-listchanges: Can't set locale; make sure $LC_* and $LANG are corre" mean?
- The error means that apt-listchanges (a tool that displays changes for upgraded packages) tried to format output using your system's locale settings but failed. This happens because either no locales are generated on your system, the locale you're using doesn't exist, or your LANG and LC_* environment variables reference a non-existent locale. While the tools still function, the error prevents proper text formatting and makes the upgrade process uncomfortable.
- How do I fix "apt-listchanges: Can't set locale; make sure $LC_* and $LANG are corre"?
- This error occurs when apt-listchanges cannot find a valid locale configuration on your system. Your locale environment variables (LC_* and LANG) are either unset, invalid, or pointing to locales that haven't been generated.
- What causes "apt-listchanges: Can't set locale; make sure $LC_* and $LANG are corre"?
- No locales have been generated on the system (most common on minimal/container installations) Environment variables reference a locale that hasn't been installed (e.g., en_US.UTF-8 is referenced but not in /etc/locale.gen) Invalid locale codes in LANG or LC_* variables (e.g., en_NL.UTF-8 which doesn't exist)
- Is the "apt-listchanges: Can't set locale; make sure $LC_* and $LANG are corre" error serious?
- It is a low-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐APT Official Documentation
- ๐Debian Wiki - Locale Configuration(Official Docs)
- ๐
- ๐
- ๐