add-apt-repository is broken with non-UTF-8 locales

Linode Staff

I'm trying to install PHP version 7.4 with NGINX, and I'm getting the following error when trying to add a repository:

sudo add-apt-repository ppa:USER/php
Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP ( for Supported Ubuntu Releases ( are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.

Debian oldstable and stable packages are provided as well:

You can get more information about the packages at

IMPORTANT: The <foo>-backports is now required on older Ubuntu releases.</foo>

BUGS&FEATURES: This PPA now has a issue tracker:


If you are using php-gearman, you need to add ppa:USER/pkg-gearman
If you are using apache2, you are advised to add ppa:USER/apache2
If you are using nginx, you are advised to add ppa:USER/nginx-mainline
   or ppa:USER/nginx
PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly:

WARNING: add-apt-repository is broken with non-UTF-8 locales, see for workaround:

LC_ALL=C.UTF-8 add-apt-repository ppa:USER/php
More info:
Press [ENTER] to continue or ctrl-c to cancel adding it

Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/", line 917, in _bootstrap_inner
File "/usr/lib/python3.7/", line 865, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3/dist-packages/softwareproperties/", line 688, in addkey_func
File "/usr/lib/python3/dist-packages/softwareproperties/", line 386, in add_key
return apsk.add_ppa_signing_key()
File "/usr/lib/python3/dist-packages/softwareproperties/", line 252, in add_ppa_signing_key
tmp_keyring, tmp_secret_keyring, signing_key_fingerprint, tmp_keyring_dir):
File "/usr/lib/python3/dist-packages/softwareproperties/", line 181, in _recv_key
"--recv", signing_key_fingerprint,
File "/usr/lib/python3.7/", line 323, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.7/", line 775, in init
restore_signals, start_new_session)
File "/usr/lib/python3.7/", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gpg': 'gpg'

1 Reply

If you navigate to the github discussion linked in the error message
(, you can see that some other users were able to work around this by installing or upgrading their server's language packages.

I wasn't able to recreate the issue myself, but it looks like the first user was able to take the following steps to do just that:

apt-get update &&
apt-get install -y language-pack-en-base &&
export LC_ALL=en_US.UTF-8 &&
export LANG=en_US.UTF-8 &&
apt-get install -y software-properties-common &&
add-apt-repository -y ppa:ondrej/php5-5.6 &&
add-apt-repository -y ppa:ondrej/mariadb-10.0 && 
apt-get update && 
apt-get -y upgrade

Another user was able to simply set their language to UTF-8:

locale-gen en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Just in case, here's a guide on installing PHP 7.4 on Ubuntu for reference: How To Install PHP 7.4 on Ubuntu 20.04/18.04/16.04


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct