软件工程

yum安装 一直出现There are no enabled repositories in “/etc/yum.repos.d“

本文主要是介绍yum安装 一直出现There are no enabled repositories in “/etc/yum.repos.d“,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

在CentOS中使用yum命令出现报错:

今天想给linux装个git 管理代码

执行命令:

1 yum -y install git 

然后出现了这么一句

error:There are no enabled repositories in "/etc/yum.repos.d", "/etc/yum/repos.d

然后就各种找问题,各种查,各种试

比如(别复制这段,这段是错的,解决不了)

vi /etc/yum.repos.dopenEuler_x86_64.repo 
#generic-repos is licensed under the Mulan PSL v2.
#You can use this software according to the terms and conditions of the Mulan PSL v2.
#You may obtain a copy of Mulan PSL v2 at:
#    http://license.coscl.org.cn/MulanPSL2
#THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
#PURPOSE.
#See the Mulan PSL v2 for more details.

[OS]
name=OS
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler

[everything]
name=everything
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/everything/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/everything/$basearch/RPM-GPG-KEY-openEuler

[EPOL]
name=EPOL
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/EPOL/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler

[debuginfo]
name=debuginfo
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/debuginfo/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/debuginfo/$basearch/RPM-GPG-KEY-openEuler

[source]
name=source
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/source/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/source/RPM-GPG-KEY-openEuler

[update]
name=update
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/update/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler

然后发现yum源根本没有

所以,首先先安装yum源

解决办法

安装yum源

1.进入目录

 cd /etc/yum.repos.d  

2.查看并删除/etc/yum.repos.d目录下所有的配置文件

1 ll   //查看当前目录的所有文件
2 rm -rf ./*  //删除当前的所有文件

然后会出现(这图是截图人家的,我当时没截图)

file

3.下载centos8的镜像源

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

然后会看到这样

file

接着

ls  //查看文件
yum -y clean all   //清除所有文件
yum -y makecache   //建立缓存

然后你可能会发现,建立缓存失败

提示是这样

Error: Failed to download metadata for repo 'base'

解决办法

切换源(任选一个命令,我这选的是1 看着来吧)

命令1:

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

命令2:

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

然后再重新建立缓存

yum makecache

如果还不成功就运行这个

yum clear all

然后建立缓存

yum makecache

然后就可以了!反正我到这一步后就可以yum -y install git 了

file

最后

yum取的源可能是CentOS-Base.repo里面的配置,也可能取的是单个配置文件里面的,比如AppStream的源可能取CentOS-AppStream.repo里面的配置,也可能取CentOS-Base.repo的配置,这两者可能会冲突,也可能不会冲突,不冲突报错可不理,若是报错,建议先重命名备份CentOS-AppStream.repo文件。

这篇关于yum安装 一直出现There are no enabled repositories in “/etc/yum.repos.d“的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!