无法从Artifactory远程Cargo Registry下载/搜索crates问题求助
私有Cargo Registry远程镜像仓库无法下载crates的问题
环境配置
- Server 1:本地类型仓库,托管私有Cargo Registry,
sparse=true,可正常发布、下载crates - Server 2:远程类型仓库,作为Server 1的镜像,
sparse=true,已缓存Server 1的Registry内容(含索引,可在Artifactory UI查看),但无法下载crates
已排除项
- Token认证无问题:可正常从Server 2的另一个本地类型私有Registry下载crates
具体错误
搜索crate失败
执行cargo search my_crate --registry CARGO_SERVER_2_REPO返回:
$ cargo search my_crate --registry CARGO_SERVER_2_REPO error: failed to retrieve search results from the registry at https://artifactory.my.server2.com/artifactory/api/cargo/cargo-repo Caused by: the remote server responded with an error (status 409 Conflict): Error while getting search results from cargo-repo
构建时无法找到crate
执行cargo build -vv返回:
$ cargo build -vv Updating CARGO_SERVER_2_REPO index error: no matching package named my_crate found location searched: registry CARGO_SERVER_2_REPO required by package another_crate v2.10.0 (....)
~/.cargo/config.toml配置
[net] git-fetch-with-cli = true retry = 3 # Registry definitions [registry] default = "crates-io" global-credential-providers = ["cargo:token"] [registries.crates-io] index = "https://crates.io" # server 1 [registries.CARGO_SERVER_1_REPO] index = "sparse+https://artifactory.my.server1.com/artifactory/api/cargo/cargo-repo/index/" [registries.CARGO_SERVER_2_REPO] index = "sparse+https://artifactory.my.server2.com/artifactory/api/cargo/cargo-repo/index/" [registries.CARGO_SERVER_2_OTHER_REPO] index = "sparse+https://artifactory.my.server2.com/artifactory/api/cargo/cargo-other-repo/index/" [http] debug = true # HTTP debugging timeout = 15 # timeout for each HTTP request, in seconds low-speed-limit = 5 # network timeout threshold (bytes/sec)
测试验证
- ✅ 从Server1的cargo-repo下载my_crate:正常
- ❌ 从Server2的cargo-repo下载my_crate:失败
- ✅ 从Server2的cargo-other-repo下载my_other_crate:正常
解决建议
- 检查远程仓库索引同步配置
- 确认Server2的远程仓库是否开启自动索引同步,手动缓存索引后,新发布crate的索引可能未自动同步,可在Artifactory UI中手动触发同步。
- 验证稀疏索引路径正确性
- 对比Server1和Server2的索引路径格式,确保Server2的
sparse+前缀后的URL与Server1结构一致,且Artifactory路由配置正确映射缓存的索引内容。
- 对比Server1和Server2的索引路径格式,确保Server2的
- 核对Artifactory远程仓库核心配置
- 确认远程仓库的
Registry URL正确指向Server1的Cargo Registry地址,而非索引地址,避免因地址填错导致请求解析失败。
- 确认远程仓库的
- 查看Artifactory日志排查细节
- 查看Server2的Artifactory日志(通常在
$ARTIFACTORY_HOME/logs/artifactory.log),根据409错误的详细日志定位冲突原因,比如索引文件权限、缓存路径冲突等。
- 查看Server2的Artifactory日志(通常在
- 重置远程仓库缓存
- 在Artifactory UI中清空Server2远程仓库的缓存,重新触发同步,避免旧索引或损坏文件导致的问题。
内容的提问来源于stack exchange,提问作者emahe
相关产品推荐
相关产品推荐

