Rhel

安裝openjdk時yum +依賴項不合邏輯

  • May 20, 2021

我們正在嘗試安裝java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64.rpm

yum localinstall java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64.rpm
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is registered to Red Hat Subscription Management, but is not receiving updates. You can use subscription-manager to assign subscriptions.
Examining java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64.rpm: 1:java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64
Marking java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.161-2.b14.el7 will be installed
--> Processing Dependency: java-1.8.0-openjdk(x86-64) = 1:1.8.0.161-2.b14.el7 for package: 1:java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64
--> Finished Dependency Resolution
Error: Package: 1:java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64 (/java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64)
          Requires: java-1.8.0-openjdk(x86-64) = 1:1.8.0.161-2.b14.el7
          Installed: 1:java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64 (installed)
              java-1.8.0-openjdk(x86-64) = 1:1.8.0.171-8.b10.el7_5
          Available: 1:java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64 (local)
              java-1.8.0-openjdk(x86-64) = 1:1.8.0.161-2.b14.el7
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

我們可以從輸出中看到:

Requires: java-1.8.0-openjdk(x86-64) = 1:1.8.0.161-2.b14.el7

但我不明白的是,我們嘗試安裝所需的相同 rpm!

java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64.rpm

那麼這裡發生了什麼?

目前安裝的rpm

rpm -qa | grep openjdk
java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64
java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64

java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-b10)
OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)

安裝它的唯一方法是通過 rpm(而不是 yum)

rpm -Va --nofiles --nodigest java-1.7.0-openjdk-devel-1.7.0.171-2.6.13.2.el7.x86_64.rpm

java-1.8.0-openjdk-devel並且java-1.8.0-openjdk版本需要完全匹配。

簡而言之:

yum downgrade java-1.8.0-openjdk-1.8.0.161-2.b14.el7
yum install java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64.rpm

我剛剛在這裡寫了這個問題的完整答案:https ://stackoverflow.com/questions/57498755/installing-python36-devel-on-rhel7-failing/57519956#57519956

您可以嘗試使用yumdownloader修復它:

# Install yumdownloader
yum install yum-utils

# Download the missing packages
yumdownloader java-1.8.0-openjdk --resolve --destdir pkgs

# Install all at once
yum install pkgs/*.rpm

引用自:https://unix.stackexchange.com/questions/535862