How to Make 'yum install' Error on Non-existent Package Names
A while ago, while writing a Dockerfile based on Amazon Linux, I encountered a silent failure during package installation using yum.
Upon closer inspection, I noticed that the following log message was displayed:
No package
available.
It turned out that I had mistyped the package name.
However, despite the error message, the exit code was 0, and the subsequent commands in the Dockerfile’s RUN command continued to execute without failing, making it difficult to notice the error.
I was surprised to learn that yum returns exit code 0 even for non-existent package names. Fortunately, there is a way to avoid this behavior.
You can use the --setopt=skip_missing_names_on_install=False
option.
For example, in a Dockerfile, you can use it like this:
RUN yum install -y --setopt=skip_missing_names_on_install=False \
package-foo \
package-bar && \
another-command
Although it may be a lengthy option, it helps to catch trivial errors early. Therefore, when using yum in a Dockerfile, I generally include this option to ensure prompt error detection.