Score:1

Unable to add ondrej repository apt in Ubuntu 20.04

kr flag

I am unable to add ondrej to my Ubuntu 20.04 installation.

sudo add-apt-repository ppa:ondrej/php

The above command returns the following error

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 363, in <module>
    addaptrepo = AddAptRepository()
  File "/usr/bin/add-apt-repository", line 41, in __init__
    self.distro.get_sources(self.sourceslist)
  File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 91, in get_sources
    raise NoDistroTemplateException(
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Ubuntu/focal

Following is the LSB release information.

Distributor ID: Ubuntu 
Description:Ubuntu 20.04.3 LTS  
Release:    20.04 
Codename:       focal

Am I doing anything wrong?

End goal: I want to be able to install PHP 8.1 extensions from apt


$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"
apt-cache policy -> https://pastebin.com/84HauP14
aptitude search ~o -> https://pastebin.com/VhaW9qWq
namei /etc/os-release -> https://pastebin.com/XwjZHkKa
cat /etc/os-release -> https://pastebin.com/CywsZvEh
kr flag
@guiverc it's mostly brand new server with very minimal changes. The output for python3 --version is "Python 3.8.10"
N0rbert avatar
zw flag
Try `sudo apt-get update; sudo apt-get install --reinstall libpython3-stdlib libpython3.8-minimal libpython3.8-stdlib python-apt-common python3 python3-apt python3-certifi python3-chardet python3-dbus python3-distro-info python3-gi python3-idna python3-minimal python3-pkg-resources python3-requests python3-requests-unixsocket python3-six python3-software-properties python3-urllib3 python3.8 python3.8-minimal software-properties-common` and then run `sudo add-apt-repository ppa:ondrej/php` again.
pLumo avatar
in flag
Please add output of `cat /etc/lsb-release`. See also: https://askubuntu.com/questions/49040/apt-could-not-find-a-distribution-template-error/
kr flag
@N0rbert tried the first command, still the same error
kr flag
@pLumo DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"
N0rbert avatar
zw flag
Please upload output of `apt-cache policy` and `aptitude search ~o` to the pastebin and share link.
kr flag
@N0rbert apt-cache policy -> https://pastebin.com/84HauP14 aptitude search ~o -> https://pastebin.com/VhaW9qWq
nobody avatar
gh flag
`namei /etc/os-release` please. It reminds me on this https://askubuntu.com/questions/1190336/software-properties-gtk-crashes-on-startup-19-10/1190636#1190636
kr flag
@nobody f: /etc/os-release d / d etc l os-release -> ../usr/lib/os-release d .. d usr d lib - os-release
nobody avatar
gh flag
Okay, the link is there. Checking correct content. `cat /etc/os-release ` Please [edit] your question for output; it is hard to read in comments without codeblock.
kr flag
@nobody added pastebin to the questions
nobody avatar
gh flag
looks normal python3 version on your system too; out of idea in the moment. And it is also not a problem with the ppa I could add it. I'm sorry.
kr flag
@nobody No worries. For the moment, I manually added the repo and public key.
abu-ahmed al-khatiri avatar
in flag
try to reinstall your python3 and add the repo again `LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php`
Score:1
kr flag

I could not get the add-apt-repository command to work so I added the repository and the signing key manually using the following commands:

  1. Open the sources.list file with a text editor (for example nano):

    sudo nano /etc/apt/sources.list
    
  2. Add the following lines to the file:

    deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu focal main 
    #deb-src https://ppa.launchpadcontent.net/ondrej/php/ubuntu focal main 
    
  3. Add the repository signing key:

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4f4ea0aae5267a6c 
    
Charles Wood avatar
cl flag
Where did you get the repository signing key?
clockw0rk avatar
ng flag
the add-apt-repository is part of the software-properties-common apt package, so you'd need to first install that one obv. -> the keys will be imported automatically when adding the repository
Score:0
cn flag

I solved with this command:

sudo apt-get install software-properties-common

As cloclw0rk wrote:

the add-apt-repository is part of the software-properties-common apt package, so you'd need to first install that one obv. -> the keys will be imported automatically when adding the repository – clockw0rk

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.