不隻是安裝software-properties-common那麼簡單……
問題
目前Deepin系統版本為15.11,貌似在15.10時切到了Debain的軟體倉庫,而不再是Ubuntu了,雖說比較穩定,但還不夠新,比如git,版本就沒有官方的新。
于是我嘗試 git官方的辦法:
sudo add-apt-repository ppa:git-core/ppa
報錯,提示未找到指令。
解決
這個問題在網上搜搜辦法,很多回答都是讓安裝一個包:
sudo apt-get install software-properties-common
是的,确實解決了 add-apt-repository 指令找不到的問題,但實際add倉庫源時,還是會出錯,你可能會看到如下内容:
Traceback (most recent call last):
File “/usr/bin/add-apt-repository”, line 95, in
sp = SoftwareProperties(options=options)
File “/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py”, line 109, in init
self.reload_sourceslist()
File “/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py”, line 599, in reload_sourceslist
self.distro.get_sources(self.sourceslist)
File “/usr/lib/python3/dist-packages/aptsources/distro.py”, line 93, in get_sources
(self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Deepin/stable
很尴尬啊兄弟!看這個報錯就大概明白,還是因為Deepin/stable不适用這種三方ppa導緻的。
我可不想就此放棄,經過一番仔細搜尋,找到一個大佬的解決辦法:
- 編輯lsb-release檔案:
sudo deepin-editor /etc/lsb-release
- 把已有内容的每行頭加#注釋掉,添加Ubuntu相關的内容:
# DISTRIB_ID=Deepin # DISTRIB_RELEASE="15.11" # DISTRIB_DESCRIPTION="Deepin 15.11 " # DISTRIB_CODENAME=stable DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS" DISTRIB_CODENAME=trusty
- 此時再試試 sudo add-apt-repository ppa:git-core/ppa 看看,卻報了另一個錯:
The most current stable version of Git for Ubuntu.
For release candidates, go to https://launchpad.net/~git-core/+archive/candidate .
More info: https://launchpad.net/~git-core/+archive/ubuntu/ppa
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keybox ‘/tmp/tmprpx7ycut/pubring.gpg’ created
gpg: failed to start the dirmngr ‘/usr/bin/dirmngr’: 沒有那個檔案或目錄
gpg: connecting dirmngr at ‘/tmp/tmprpx7ycut/S.dirmngr’ failed: 沒有那個檔案或目錄
gpg: keyserver receive failed: No dirmngr
- 不要慌,他說沒有dirmngr,我們就安一個:
sudo apt-get install dirmngr
最後再add倉庫ppa就不會報錯了。
搞定之後,就能順利安裝最新的git:
sudo apt-get update
sudo apt-get install git