我在 Ubuntu 22.04 LTS 上安装了 git,但最近它不知何故被卸载了。git --version
显示Command 'git' not found, but can be installed with: sudo apt install git
.
尝试再次安装,我收到此错误:
The following packages have unmet dependencies:
git : Depends: git-man (< 1:2.39.1-.) but 1:2.39.2-0ppa1~ubuntu22.04.1 is to be installed
E: Unable to correct problems, you have held broken packages.
我已经跑了sudo apt update
sudo apt upgrade
,并确保没有任何阻碍。sudo apt install -f
也没有工作。
编辑:apt policy
显示:
Package files:
100 /var/lib/dpkg/status
release a=now
500 http://packages.microsoft.com/repos/code stable/main armhf Packages
release o=code stable,a=stable,n=stable,l=code stable,c=main,b=armhf
origin packages.microsoft.com
500 http://packages.microsoft.com/repos/code stable/main arm64 Packages
release o=code stable,a=stable,n=stable,l=code stable,c=main,b=arm64
origin packages.microsoft.com
500 http://packages.microsoft.com/repos/code stable/main amd64 Packages
release o=code stable,a=stable,n=stable,l=code stable,c=main,b=amd64
origin packages.microsoft.com
500 https://dl.google.com/linux/chrome/deb stable/main amd64 Packages
release v=1.0,o=Google LLC,a=stable,n=stable,l=Google,c=main,b=amd64
origin dl.google.com
500 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy/main i386 Packages
release v=22.04,o=LP-PPA-git-core,a=jammy,n=jammy,l=Git stable releases,c=main,b=i386
origin ppa.launchpadcontent.net
500 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy/main amd64 Packages
release v=22.04,o=LP-PPA-git-core,a=jammy,n=jammy,l=Git stable releases,c=main,b=amd64
origin ppa.launchpadcontent.net
500 http://security.ubuntu.com/ubuntu jammy-security/multiverse i386 Packages
release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=multiverse,b=i386
origin security.ubuntu.com
500 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=multiverse,b=amd64
origin security.ubuntu.com
500 http://security.ubuntu.com/ubuntu jammy-security/universe i386 Packages
release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=universe,b=i386
origin security.ubuntu.com
500 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=universe,b=amd64
origin security.ubuntu.com
500 http://security.ubuntu.com/ubuntu jammy-security/restricted i386 Packages
release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=restricted,b=i386
origin security.ubuntu.com
500 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=restricted,b=amd64
origin security.ubuntu.com
500 http://security.ubuntu.com/ubuntu jammy-security/main i386 Packages
release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=main,b=i386
origin security.ubuntu.com
500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-security,n=jammy,l=Ubuntu,c=main,b=amd64
origin security.ubuntu.com
100 http://us.archive.ubuntu.com/ubuntu jammy-backports/universe i386 Packages
release v=22.04,o=Ubuntu,a=jammy-backports,n=jammy,l=Ubuntu,c=universe,b=i386
origin us.archive.ubuntu.com
100 http://us.archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-backports,n=jammy,l=Ubuntu,c=universe,b=amd64
origin us.archive.ubuntu.com
100 http://us.archive.ubuntu.com/ubuntu jammy-backports/main i386 Packages
release v=22.04,o=Ubuntu,a=jammy-backports,n=jammy,l=Ubuntu,c=main,b=i386
origin us.archive.ubuntu.com
100 http://us.archive.ubuntu.com/ubuntu jammy-backports/main amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-backports,n=jammy,l=Ubuntu,c=main,b=amd64
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy-updates/multiverse i386 Packages
release v=22.04,o=Ubuntu,a=jammy-updates,n=jammy,l=Ubuntu,c=multiverse,b=i386
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-updates,n=jammy,l=Ubuntu,c=multiverse,b=amd64
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe i386 Packages
release v=22.04,o=Ubuntu,a=jammy-updates,n=jammy,l=Ubuntu,c=universe,b=i386
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-updates,n=jammy,l=Ubuntu,c=universe,b=amd64
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy-updates/restricted i386 Packages
release v=22.04,o=Ubuntu,a=jammy-updates,n=jammy,l=Ubuntu,c=restricted,b=i386
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-updates,n=jammy,l=Ubuntu,c=restricted,b=amd64
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages
release v=22.04,o=Ubuntu,a=jammy-updates,n=jammy,l=Ubuntu,c=main,b=i386
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
release v=22.04,o=Ubuntu,a=jammy-updates,n=jammy,l=Ubuntu,c=main,b=amd64
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy/multiverse i386 Packages
release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=multiverse,b=i386
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages
release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=multiverse,b=amd64
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy/universe i386 Packages
release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=universe,b=i386
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=universe,b=amd64
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy/restricted i386 Packages
release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=restricted,b=i386
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages
release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=restricted,b=amd64
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy/main i386 Packages
release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=main,b=i386
origin us.archive.ubuntu.com
500 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
release v=22.04,o=Ubuntu,a=jammy,n=jammy,l=Ubuntu,c=main,b=amd64
origin us.archive.ubuntu.com
Pinned packages:
编辑 2:通过软件和更新删除现有的 PPA 是有效的。https://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependency-after-adding-a-ppa
答案1
我也有同样的问题。我在某个时候添加了 ppa:git-core/ppa 并忘记了它。您的 apt 政策中也有它。
apt policy |grep git
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
500 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy/main i386 Packages
release v=22.04,o=LP-PPA-git-core,a=jammy,n=jammy,l=Git stable releases,c=main,b=i386apt policy |grep git
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
500 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy/main i386 Packages
release v=22.04,o=LP-PPA-git-core,a=jammy,n=jammy,l=Git stable releases,c=main,b=i386
我发现的最简单的解决方案是删除 PPA直到维护者解决该问题。
sudo apt install ppa-purge
sudo ppa-purge ppa:git-core/ppa
sudo apt update
sudo apt install git
然而,它确实给我留下了一个稍旧版本的 git。如果有人找到解决依赖性的方法,请分享。希望包维护者尽快做到这一点:)