You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WSL Ubuntu中如何解决‘E: Malformed entry 1 in list file’错误?

MongoDB Atlas CLI安装Apt源错误解决方法

问题概述

按照MongoDB Atlas CLI安装指南操作时,创建Ubuntu源文件后执行sudo apt-get update报错:

E: Malformed entry 1 in list file /etc/apt/sources.list.d/mongodb-org-6.3.list (Component)
E: The list of sources could not be read.

已尝试修改版本号、调整源字段、重建文件、更新系统等操作,问题未解决,怀疑与WSL环境相关。

问题根源

  1. 版本不支持Apt源:MongoDB 6.3是非LTS版本,官方仅为LTS版本(如6.0、5.0)提供Apt源,因此6.3版本的源URL无内容。
  2. 源文件格式错误:原命令中的URL包含多余的dists/路径,不符合Apt源的格式规范。

解决步骤

  • 切换至LTS版本:选择MongoDB官方支持的LTS版本,推荐使用6.0 LTS。
  • 删除错误源文件:
    sudo rm /etc/apt/sources.list.d/mongodb-org-6.3.list
    
  • 创建正确的源文件:执行以下命令生成符合格式的源文件:
    echo "deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
    
  • 添加GPG验证密钥:
    wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
    
  • 更新源并安装Atlas CLI:
    sudo apt-get update
    sudo apt-get install mongodb-atlas-cli
    

WSL环境额外排查项

  • 验证网络连通性:执行ping repo.mongodb.org确认WSL能正常访问MongoDB源服务器。
  • 检查源文件内容:手动编辑源文件确认无多余空格或特殊字符:
    sudo nano /etc/apt/sources.list.d/mongodb-org-6.0.list
    
    确保文件内容仅为:
    deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/6.0 multiverse
    

内容的提问来源于stack exchange,提问作者Kitty

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 11:55:26