我正在嘗試在我的 ubuntu 機器上安裝 openjdk-11-jre-headless 或 default-jre,但無論我做什麼,我在執行此操作時都會收到一些錯誤訊息。
" The following packages have unmet dependencies:
openjdk-11-jre-headless : Depends: initscripts but it is not installable
E: Unable to correct problems, you have held broken packages "
" The following packages have unmet dependencies:
default-jre : Depends: default-jre-headless (= 2:1.11-68ubuntu1~18.04.1) but it is not going to be installed
Depends: openjdk-11-jre but it is not going to be installed
E: Unable to correct problems, you have held broken packages. "
我已經嘗試過這些命令來解決問題,但沒有運氣..
- sudo apt-get update --修復缺失
- sudo apt-get 更新
- sudo apt-get clean
- sudo apt-get 自動刪除
- sudo dpkg 重新配置-a
- 須藤apt安裝-f
我用 aptitude 嘗試了同樣的事情:
- aptitude 安裝default-jre 但沒有運氣...
有什麼想法如何修復“損壞的包”和依賴性問題嗎?
詳細的系統訊息
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
apt更新:
- Hit:1 example/packages/live/example bionic InRelease
- Hit:2 ee.archive.ubuntu.com/ubuntu bionic InRelease
- Hit:3 ee.archive.ubuntu.com/ubuntu bionic-updates InRelease
- Hit:4 ee.archive.ubuntu.com/ubuntu bionic-backports InRelease
- Hit:5 ee.archive.ubuntu.com/ubuntu bionic-security InRelease
- Hit:6 ppa.launchpad.net/nginx/stable/ubuntu trusty InRelease
- Hit:7 ppa.launchpad.net/openjdk-r/ppa/ubuntu trusty InRelease
- Hit:8 adoptopenjdk.jfrog.io/adoptopenjdk/deb bionic InRelease
- 請注意 -example 是我選擇重命名的有效儲存庫 -
Reading package lists... Done Building dependency tree Reading state information...
Done All packages are up to date.
apt-cache 策略截圖:
- apt-cache 策略預設 jre
- apt-cache 策略 default-jre-headless
- apt-cache 策略 openjdk-11-jre
答案1
問題產生的原因是:
一些 apt 儲存庫包含伺服器和軟體不再需要的過時儲存庫。他們引發了衝突。
從 /etc/apt/sources.d/ repo.list 檔案中刪除這些儲存庫:
德布http://ppa.launchpad.net/nginx/stable/ubuntu值得信賴的主要債務http://ppa.launchpad.net/openjdk-r/ppa/ubuntu值得信賴的主要
刪除後default-jre和openjdk-11-headless安裝成功
答案2
只有這個對我有用:
sudo rm /etc/apt/sources.list
sudo software-properties-gtk
and than apt update
sudo apt install default-jre
答案3
dpkg --get-selections | grep "\<hold$
如果有任何東西恢復原樣,請修復保留並再次嘗試安裝