I have an environment variable set in my (docker) centos environment:
[arman@7b33ffd8619e ~]$ echo $YUM0
yumrepo.myhost.com
Note that this also works when I prepend the echo
command with sudo
.
As per the centos documentation;
$YUM0-9 This is replaced with the value of the shell environment variable of the same name. If the shell environment variable does not exist, then the configuration file variable will not be replaced.
However, when I try to install anything with yum
from my container I get an error message clearly indicating that the environment variable is not being picked up by yum
:
[arman@7b33ffd8619e ~]$ sudo yum install less
Loaded plugins: fastestmirror
http://$YUM0/x86_64/centos/7.2.1511/base/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: $YUM0; Name or service not known"
Trying other mirror.
One of the configured repositories failed (centos),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Disable the repository, so yum won't use it by default. Yum will then
just ignore the repository until you permanently enable it again or use
--enablerepo for temporary usage:
yum-config-manager --disable centos
4. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=centos.skip_if_unavailable=true
failure: repodata/repomd.xml from centos: [Errno 256] No more mirrors to try.
http://$YUM0/x86_64/centos/7.2.1511/base/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: $YUM0; Name or service not known"
I am running the following versions:
[arman.schwarz@7b33ffd8619e ~]$ cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)
[arman.schwarz@7b33ffd8619e ~]$ yum --version
3.4.3
Manually modifying my .repo
files in /etc/yum.repos.d
to use the repository name rather than relying on the environment variable causes yum
to install without issue, proving that this is not an issue with the repo itself.
Running export YUM0=yumrepo.myhost.com
has no effect.
How can I make the YUM0
environment variable available to yum
?
sudo
is stripping it out; confirm or deny with:sudo env | grep YUM0
sudo echo $YUM0
is a false positive; YUM0 would be expanded before sudo ran the echo)