Bug 736694 - 'yum install non-existent-package -y' returns zero
'yum install non-existent-package -y' returns zero
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: yum (Show other bugs)
5.7
Unspecified Unspecified
high Severity high
: rc
: ---
Assigned To: James Antill
Red Hat Satellite QA List
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-08 08:40 EDT by Šimon Lukašík
Modified: 2014-01-21 01:24 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-09-16 03:13:29 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Šimon Lukašík 2011-09-08 08:40:20 EDT
Description of problem:
When installing a non-existent package, the yum tool emits the error
message. However, it does not return non zero value.

Version-Release number of selected component (if applicable):
yum-3.2.22-37.el5

How reproducible:
deterministic

Steps to Reproduce:
1. yum install blablabumbac -y
2. echo $?
3.
  
Actual results:
# yum install blablabumbac -y
Loaded plugins: rhnplugin, security
Setting up Install Process
No package blablabumbac available.
Nothing to do
# echo $?
0

Expected results:
# yum install blablabumbac -y
Loaded plugins: rhnplugin, security
Setting up Install Process
No package blablabumbac available.
Nothing to do
# echo $?
1

Additional info:
Comment 1 Phil Knirsch 2011-09-14 07:50:18 EDT
This is working as intended. Having no packages to update is not considered an error in yum, nor is not finding any packages to update via the glob given on the commandline.

If you want to check if there are any updates available generally or for the given globs you can always run:

  yum check-update [globs]

and check the return value of that:

       check-update
              Implemented so you could know if your machine had any updates that needed to be applied without running it interactively. Returns exit value of 100 if there are packages available for an  update.
              Also returns a list of the packages to be updated in list format. Returns 0 if no packages are available for update. Returns 1 if an error occurred.  Running in verbose mode also shows obsoletes.

If you do that for a non existing package you will get 0 as a return value, but again that would be the same as no updates available.

If you want to check if a package exists you can use

  yum info blablabumbac

where you will get a 1 as a return value if the package doesn't exist.

The reason for this is that the update operation itself is not considered to be failing if no packages are updated. That just means that your system is as current as possible. On the other hand for info you directly specify that you want information about a specific package, and when that doesn't exist it will be an error.

Hope that helps,

Thanks & regards, Phil
Comment 2 Šimon Lukašík 2011-09-14 08:25:33 EDT
(In reply to comment #1)
> This is working as intended. Having no packages to update is not considered an
> error in yum, nor is not finding any packages to update via the glob given on
> the commandline.
Right.

> 
> If you want to check if there are any updates available generally or for the
> given globs you can always run:
> 
>   yum check-update [globs]
> 
> and check the return value of that:
> 
>        check-update
>               Implemented so you could know if your machine had any updates
> that needed to be applied without running it interactively. Returns exit value
> of 100 if there are packages available for an  update.
>               Also returns a list of the packages to be updated in list format.
> Returns 0 if no packages are available for update. Returns 1 if an error
> occurred.  Running in verbose mode also shows obsoletes.
> 
> If you do that for a non existing package you will get 0 as a return value, but
> again that would be the same as no updates available.
> 
Right.

> If you want to check if a package exists you can use
> 
>   yum info blablabumbac
> 
> where you will get a 1 as a return value if the package doesn't exist.
> 
Right.

> The reason for this is that the update operation itself is not considered to be
> failing if no packages are updated. That just means that your system is as
> current as possible. On the other hand for info you directly specify that you
> want information about a specific package, and when that doesn't exist it will
> be an error.
This is all correct.

But the description (in comment 0) of this bugzilla is not about
the 'yum update' nor the 'yum check-update' operations. This bugzilla
is about 'yum install' operation.

Even though the above said, We still hope that 'yum install' operation
is similar to 'yum info' operation in the way it should assert for
non-existent packages.

Reopening.
Comment 3 Petr Sklenar 2011-09-15 05:05:23 EDT
see also to another releases:

F15:
[root@freelab ~]# yum install blaublevolebum -y
Loaded plugins: langpacks, presto, refresh-packagekit
Setting up Install Process
No package blaublevolebum available.
Error: Nothing to do
[root@freelab ~]# echo $?
1
[root@freelab ~]# rpm -q yum
yum-3.2.29-8.fc15.noarch
--
RHEL6:
[root@dhcp-25-114 ~]# yum install asas -y
Loaded plugins: product-id, refresh-packagekit, rhnplugin, subscription-manager
Updating Red Hat repositories.
Setting up Install Process
No package asas available.
Error: Nothing to do
[root@dhcp-25-114 ~]# echo $?
1
[root@dhcp-25-114 ~]# rpm -q yum
yum-3.2.29-17.el6.noarch
========

its 2:1 for returning 1.
I guess it should be same on rhel5 or is there REGRESSION on rhel6 compare to rhel5?
Comment 4 James Antill 2011-09-15 15:57:58 EDT
 Yeh, we did fix this for RHEL-6 ... so now both "yum list" and "yum install" will exit 1 if all their arguments don't exist. But it was decided that'd be too big of a change for RHEL-5 ... Eg. some customer has:

#! /bin/bash -e

# Get random stuff from channels.
yum install foo
yum install bar
yum install baz

...where bar is in a channel that might not be enabled.
Comment 5 Petr Sklenar 2011-09-16 03:13:29 EDT
I see, Thanks much for the explanation. 
closing for rhel5

Note You need to log in before you can comment on or make changes to this bug.