简体   繁体   English

无法修复损坏的 Git 安装在 Ubuntu 上

[英]Can't Fix Broken Git installation on Ubuntu

I was trying to install git on ubuntu, but there is an error when I try to install or fix broken git installation.我试图在 ubuntu 上安装 git,但是当我尝试安装或修复损坏的 git 安装时出现错误。 This is the error :这是错误

cp: cannot stat '/usr/lib/git-core/git': No such file or directory
dpkg: error processing archive /var/cache/apt/archives/git_1%3a2.17.1-1ubuntu0.8_amd64.deb (--unpack):
 new git package pre-installation script subprocess returned error exit status 1
dpkg-query: warning: files list file for package 'git' missing; assuming package has no files currently installed
dpkg-query: warning: files list file for package 'git' missing; assuming package has no files currently installed
Errors were encountered while processing:
 /var/cache/apt/archives/git_1%3a2.17.1-1ubuntu0.8_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried other possibles solutions, I will list here:我尝试了其他可能的解决方案,我将在这里列出:

  • apt --fix-broken install . apt --fix-broken install Error: The same problem as above.错误:与上述相同的问题。
  • apt purge git . apt purge git Show me to make an apt fix broken install让我做一个apt fix broken install
  • sudo dpkg -i --force-overwrite /var/cache/apt/archives/git_1%3a2.17.1-1ubuntu0.8_amd64.deb . sudo dpkg -i --force-overwrite /var/cache/apt/archives/git_1%3a2.17.1-1ubuntu0.8_amd64.deb Error: dpkg-query: warning: files list file for package 'git' missing; assuming package has no files currently installed错误: dpkg-query: warning: files list file for package 'git' missing; assuming package has no files currently installed dpkg-query: warning: files list file for package 'git' missing; assuming package has no files currently installed
  • I tried to remove all files inside dpkg/updates , apt/lists , apt/*.bin , and clen apt-get, to try to force the installation, but again the same error above.我试图删除dpkg/updatesapt/listsapt/*.bin和 clen apt-get 中的所有文件,以尝试强制安装,但同样出现上述错误。
sudo rm -rf /var/lib/dpkg/updates/*
sudo rm -rf /var/lib/apt/lists/*
sudo rm /var/cache/apt/*.bin
sudo apt-get clean
sudo apt-get autoremove
sudo apt-get update
sudo dpkg --configure -a
sudo apt-get install -f
  • I tryed to remove the git .deb file from /var/cache/apt/archives and install git again, but doesn't work.我尝试从/var/cache/apt/archives中删除 git .deb文件并再次安装 git,但不起作用。

I resolved the problem with the commands below:我用以下命令解决了这个问题:

sudo apt-mark hold git
sudo dpkg -r --force-depends git

And then install git-core然后安装git-core

sudo apt install git-core

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM