我正在尝试在 Debian Bookworm 上安装 QGIS。然而,在添加仓库时,新源不被识别:
```bash
add-apt-repository "deb https://qgis.org/${os} ${release} main" && apt-get update
仓库:'deb https://qgis.org/debian bookworm main'
描述:
代号为 bookworm 的存档,组件:main
更多信息:https://qgis.org/debian
添加仓库。
按 [ENTER] 继续或 Ctrl-c 取消。
向 /etc/apt/sources.list.d/archive_uri-https_qgis_org_debian-bookworm.list 添加 deb 条目
向 /etc/apt/sources.list.d/archive_uri-https_qgis_org_debian-bookworm.list 添加禁用的 deb-src 条目
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
读取软件包列表... 完成
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
读取软件包列表... 完成
```
此外,`apt-cache` 显示的版本过时,且不是来自 `https://qgis.org/`。
然而,当再次运行 `add-apt-repository` 时,它却可以工作?!
```bash
root@ddc3e7ea6d37:/# add-apt-repository "deb https://qgis.org/${os} ${release} main" && apt-get update
仓库:'deb https://qgis.org/debian bookworm main'
描述:
代号为 bookworm 的存档,组件:main
更多信息:https://qgis.org/debian
添加仓库。
按 [ENTER] 继续或 Ctrl-c 取消。
向 /etc/apt/sources.list.d/archive_uri-https_qgis_org_debian-bookworm.list 添加 deb 条目
向 /etc/apt/sources.list.d/archive_uri-https_qgis_org_debian-bookworm.list 添加禁用的 deb-src 条目
Hit:2 http://deb.debian.org/debian bookworm InRelease
Hit:3 http://deb.debian.org/debian bookworm-updates InRelease
Get:1 https://debian.qgis.org/debian bookworm InRelease [5482 B]
Hit:4 http://deb.debian.org/debian-security bookworm-security InRelease
Get:5 https://debian.qgis.org/debian bookworm/main amd64 Packages [58.8 kB]
获取 64.3 kB,用时 0s (160 kB/s)
读取软件包列表... 完成
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:3 http://deb.debian.org/debian bookworm-updates InRelease
Hit:2 https://debian.qgis.org/debian bookworm InRelease
Hit:4 http://deb.debian.org/debian-security bookworm-security InRelease
读取软件包列表... 完成
```
我需要创建一个带有 QGIS 的 Docker 镜像,所以运行命令两次似乎不是一个好的解决方案。
你知道这是为什么吗?
编辑:
第一次运行后 `/etc/apt/sources.list.d/archive_uri-https_qgis_org_debian-bookworm.list` **是空的**。第二次运行后它包含:
```bash
deb https://qgis.org/debian bookworm main
# deb-src https://qgis.org/debian bookworm main
```
这是一个已知问题,解决方法是像你发现的那样,运行两次
add-apt-repository
。顺便说一下,你不需要手动运行
apt-get update
,add-apt-repository
会自动更新缓存。