add-apt-repository throws Python error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5

The software-properties-common is buggy, so if have a time, please report this as a bug in software-properties-common.

A better workaround was pointed out in the issue tracker that uses specific unicode locale when adding the repository

LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php5-5.6

Try installing a language pack which may correct your issues with encoding, e.g.

sudo apt-get install language-pack-en

This will provide English translation data updates for all supported packages (including Python).

See: UnicodeEncodeError: 'ascii' codec can't encode character.

Otherwise set the locale settings manually, e.g.

$ locale -a | grep "^en_.\+UTF-8"
en_GB.UTF-8
en_US.UTF-8
$ export LC_ALL=en_GB.UTF-8
$ export LANG=en_GB.UTF-8

Related: locale error with apt-get install


If you are in docker, this worked for me:

RUN LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php

An after:

RUN apt-get update
RUN apt-get install -y php7.2