This Perl warning occurs when system locale settings are not properly configured on Debian/Ubuntu systems. The warning appears when Perl detects that environment variables like LC_ALL, LANG, or LANGUAGE are unset or point to unsupported locales. It can be fixed by generating missing locales or setting appropriate environment variables.
Perl emits this warning when it cannot load the locale specified by your environment variables. This typically happens on fresh Debian or Ubuntu installations where locales haven't been generated, or when connecting via SSH and locale environment variables are passed from a client machine that has different locale settings. Perl falls back to a default locale (like en_US.UTF-8) but still warns you about the mismatch.
First, see which locales are currently available:
locale -aThis lists all installed locales. Common ones are en_US.UTF-8, C, and C.UTF-8.
If you need a specific locale that's missing, generate it:
sudo locale-gen en_US.UTF-8Then update the system locale configuration:
sudo dpkg-reconfigure localesSelect at least one locale (usually en_US.UTF-8) and confirm it as the default.
Add these variables to your shell profile (~/.bashrc, ~/.bash_profile, or ~/.zshrc):
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8Then reload your shell:
source ~/.bashrcIf you're connecting remotely via SSH, your client machine's locale variables may be forwarded to the server. On your local machine, edit ~/.ssh/config:
Host *
SendEnv LANG LC_*Change to:
Host *
SendEnv LANGOr comment out the SendEnv line entirely to prevent locale forwarding.
If you need an immediate solution without reconfiguring the system:
export LC_ALL=COr:
export LC_ALL=C.UTF-8This disables locale-specific behavior and resolves the warning. This is temporary and only lasts for the current session.
For Docker containers, add locale generation to your Dockerfile before installing Perl:
RUN apt-get update && apt-get install -y locales && \
locale-gen en_US.UTF-8 && \
update-locale LANG=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8The LC_ALL variable takes precedence over both LANG and individual LC_* variables (like LC_CTYPE, LC_NUMERIC, etc.). Setting LC_ALL=C disables all locale-specific behavior but is less efficient than properly configuring locales. On systems like Arch Linux, uncomment desired locales in /etc/locale.gen and run 'locale-gen' instead of using dpkg-reconfigure.
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