1

On centos 7 (docker), I see yum install command with several packages succeeds even if some are not found. This is nasty for scripting :-(

(in this example golang not found because I didn't add EPEL repo)

[root@1ec73c6c476b /]# yum install golang nano
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: centos.interhost.net.il
 * extras: centos.interhost.net.il
 * updates: centos.interhost.net.il
No package golang available.
Resolving Dependencies
--> Running transaction check
---> Package nano.x86_64 0:2.3.1-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================
 Package                                    Arch                                         Version                                             Repository                                  Size
==============================================================================================================================================================================================
Installing:
 nano                                       x86_64                                       2.3.1-10.el7                                        base                                       440 k

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

Total download size: 440 k
Installed size: 1.6 M
Is this ok [y/d/N]: y
Downloading packages:
nano-2.3.1-10.el7.x86_64.rpm                                                                                                                                           | 440 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : nano-2.3.1-10.el7.x86_64                                                                                                                                                   1/1 
  Verifying  : nano-2.3.1-10.el7.x86_64                                                                                                                                                   1/1 

Installed:
  nano.x86_64 0:2.3.1-10.el7                                                                                                                                                                  

Complete!

[root@1ec73c6c476b /]# echo $?
0

It only exits 0 if all specified packages are missing:

[root@1ec73c6c476b /]# yum install foo
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: centos.interhost.net.il
 * extras: centos.interhost.net.il
 * updates: centos.interhost.net.il
No package foo available.
Error: Nothing to do

[root@1ec73c6c476b /]# yum install golang foo
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: centos.interhost.net.il
 * extras: centos.interhost.net.il
 * updates: centos.interhost.net.il
No package golang available.
No package foo available.
Error: Nothing to do

According to https://access.redhat.com/solutions/321603, the latter behavior is new in RHEL 6, per this changelog: https://github.com/rpm-software-management/yum/blob/master/ChangeLog#L3749-L3762

... If all package(s) are "not found", yum turns the message "Nothing to do" into an error (returns 1, atm). ...thus:

  1. yum install -y a b && echo worked
    This will echo "worked" if either a or b is installed after yum finishes, but tries to install both.
  2. yum install a && yum install b && echo worked
    This will echo "worked" if both are installed (and if a is not available, b will not even try to be installed).

But presumably, a single yum install a b is faster and in complex cases better at dependency resolution than yum install a && yum install b (?)

Q: Is there any flag/config to install many packages in one yum invocation, requiring all to be found for success?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.