解决yum安装报错Protected multilib versions的问题

  • Post category:Linux

问题背景:

在使用yum命令安装软件包时,经常会遇到 “Protected multilib versions” 错误,这是由于当前系统启用了需要保护软件库完整性的特征导致的。本文将提供一些解决此问题的完整攻略。

步骤一:查询当前活动的保护特征

要解决yum安装报错“Protected multilib versions”的问题,我们必须先查询当前活动的保护特征。执行以下命令:

$ grep protect /etc/yum.conf

如果有输出,则表明保护特征被启用。结果如下所示:

protect=1

步骤二:停用保护特征

要停用保护特征,请编辑/etc/yum.conf文件,并将其设置为“0”,执行以下命令:

$ sudo nano /etc/yum.conf

定位到protect行,并将其值更改为0,如下所示:

[main]
gpgcheck=1
installonly_limit=5
clean_requirements_on_remove=true
best=True
#针对保护特征
protect=0

保存文件并退出nano编辑器。

步骤三:清除缓存

清除旧的yum缓存,以确保系统能够重新生成缓存以反映新的设置。执行以下命令:

$ sudo yum clean all

步骤四:再次安装软件包

现在,我们可以使用yum命令安装我们所需的软件包了。

示例1:安装htop工具

$ sudo yum install htop

输出:

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
Resolving Dependencies
--> Running transaction check
---> Package htop.x86_64 0:2.2.0-3.el8 will be installed
--> Processing Dependency: ncurses-compat-libs for package: htop-2.2.0-3.el8.
    x86_64
--> Running transaction check
---> Package ncurses-compat-libs.x86_64 0:6.1-7.20180224.el8 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================
 Package                Arch           Version                  Repository
                                                                           Size
===============================================================================
Installing:
 htop                   x86_64         2.2.0-3.el8              baseos    113 k
Installing dependencies:
 ncurses-compat-libs    x86_64         6.1-7.20180224.el8       baseos     78 k

Transaction Summary
===============================================================================
Install  2 Packages

Total download size: 191 k
Installed size: 465 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): ncurses-compat-libs-6.1-7.20180224.el8.x86_64.rpm      59 kB/s |  78 kB     00:01    
(2/2): htop-2.2.0-3.el8.x86_64.rpm                             80 kB/s | 113 kB     00:01    
-------------------------------------------------------------------------------
Total                                                             50 kB/s | 191 kB     00:03     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : ncurses-compat-libs-6.1-7.20180224.el8.x86_64          1/2 
  Installing       : htop-2.2.0-3.el8.x86_64                                2/2 
  Running scriptlet: htop-2.2.0-3.el8.x86_64                                2/2 
  Verifying        : ncurses-compat-libs-6.1-7.20180224.el8.x86_64          1/2 
  Verifying        : htop-2.2.0-3.el8.x86_64                                2/2 

Installed:
  htop-2.2.0-3.el8.x86_64          ncurses-compat-libs-6.1-7.20180224.el8.x86_64         

Complete!

示例2:安装tree工具

$ sudo yum install tree

输出:

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.8.0-14.el8 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================
 Package             Arch             Version                Repository  Size
===============================================================================
Installing:
 tree                x86_64           1.8.0-14.el8           baseos     56 k

Transaction Summary
===============================================================================
Install  1 Package

Total download size: 56 k
Installed size: 111 k
Is this ok [y/N]: y
Downloading Packages:
tree-1.8.0-14.el8.x86_64.rpm                            280 kB/s |  56 kB     00:00    
-------------------------------------------------------------------------------
Total                                                   107 kB/s |  56 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : tree-1.8.0-14.el8.x86_64                                1/1 
  Verifying        : tree-1.8.0-14.el8.x86_64                                1/1 

Installed:
  tree-1.8.0-14.el8.x86_64                                                       

Complete!

现在,我们以root身份安装软件包而不会遇到“Protected multilib versions”错误,安装已成功完成。

注意:在完成操作后,请立即将颜色值更改为“protect=1”,并重新打开保护特征。

希望这篇文章能够帮助你解决“Protected multilib versions”的问题。