英文:
Why does yum not read updates to RPM repository file?
问题
On Amazon Linux,我正在按照指南安装Node.js v16,使用NodeSource RPM:
$ curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash
上述命令会更新/etc/yum/yum.repos.d/nodesource-el7.repo
中的仓库文件,以便当我运行yum list --showduplicates nodejs
时,yum会显示所有可用的Node.js版本16。没有问题。
但后来,我决定安装v20。因此,我运行了下面的命令,再次修改/etc/yum/yum.repos.d/nodesource-el7.rep
。这应该让yum发现Node.js v20的发行版:
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
问题是,当我尝试使用sudo yum install nodejs
安装Node.js v20时,yum会安装v16而不是v20。当我运行yum list --showduplicates nodejs
时,yum仍然显示v16 Node.js的列表,而不是v20。就好像yum不知道.repo已经更新一样。
我尝试使用yum clean all
希望yum能够发现v20的Node.js仓库,但它不起作用。我使用yum clean metadata
只能偶尔有效。随着我在v16和v20之间进行实验,最终yum list nodejs
很少更新其列表,尽管Node.js的.repo已经更新。
问题:我如何告诉yum根据/etc/yum.repos.d/
中的更新来更新其可发现的软件包?(在我的情况下是nodesource-el7.repo
。)
英文:
On Amazon Linux, I was following the guide of installing Node.js v16 via NodeSource RPM:
$ curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash
The command above updates the repository file in /etc/yum/yum.repos.d/nodesource-el7.repo
, such that when I run yum list --showduplicates nodejs
, yum shows me all available version 16 of Node.js. No problem here.
But then, I decided to install v20 instead. So I run the command below, modifying yet again the /etc/yum/yum.repos.d/nodesource-el7.rep
. This should let yum discover v20 distributions of Node.js:
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
The problem is, when I try to install Node.js v20 using sudo yum install nodejs
, yum installs v16 instead. When I run yum list --showduplicates nodejs
, yum still shows me the list of v16 Node.js, and not v20. It's as if yum doesn't know that the .repo was updated.
I try to use yum clean all
in hopes for yum to discover the v20 Node.js repository, but it doesn't work. I used yum clean metadata
and it worked for only a couple of times. As I kept experimenting by switching between v16 and v20 installations, in the end yum list nodejs
rarely updates its list despite updates to the Node.js .repo.
Question: how do I tell yum to update its discoverable packages according to updates in /etc/yum.repos.d/
? (The nodesource-el7.repo
in my case.)
答案1
得分: 0
以下是您要翻译的内容:
在尝试了不同的方法,查阅文档并在此过程中经历了许多麻烦之后,似乎下面的命令是确保Yum正确读取其存储库的绝对可靠的方法。
sudo rm -rf /var/cache/yum && yum clean all && yum makecache
yum clean all
清理各种临时文件。yum makecache
重新创建Yum缓存。似乎yum clean all
不清除HTTP层面的缓存,这个命令修复了这个问题。rm -rf /var/cache/yum
是为了在上述前两个命令带来的不一致性。也就是说,在yum list <package>
中显示的版本可能与通过yum install <package>
安装的版本不同。删除缓存目录可以修复这个问题。
英文:
After trying out different things, scouring the docs and going through a lot of trouble in the process, it seems that the command below is a fool-proof way to ensure that Yum reads its repositories correctly.
sudo rm -rf /var/cache/yum && yum clean all && yum makecache
yum clean all
cleans all sorts of temporary files.yum makecache
recreates the Yum cache. It seems thatyum clean all
does not clear caches on the HTTP layer, and this command fixes that.rm -rf /var/cache/yum
is to somehow fix the inconsistency brought by the previous 2 commands above. That is, the version displayed inyum list <package>
can differ from the version installed viayum install <package>
. Deleting the cache directory somehow fixes this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论