【发布时间】:2018-12-19 18:28:21
【问题描述】:
我已经为 Rust 完成了一个 MuPDF 绑定,我想将它作为一个 crate 从它的 git 存储库中导入。
我的 Cargo.toml 文件是这样的:
[package]
name = "package_name"
version = "0.1.0"
authors = ["me"]
[dependencies]
mupdf-sys = {git = "https://github.com/bruno-sm/mupdf-sys.git"}
问题在于 MuPDF 将其第三方库存储为具有相对路径的 git 子模块。这是 .gitmodules 文件的摘录:
[submodule "thirdparty/jbig2dec"]
path = thirdparty/jbig2dec
url = ../jbig2dec.git
[submodule "thirdparty/mujs"]
path = thirdparty/mujs
url = ../mujs.git
当我运行cargo build 时出现以下错误
Updating git repository `https://github.com/bruno-sm/mupdf-sys`
error: failed to load source for a dependency on `mupdf-sys`
Caused by:
Unable to update https://github.com/bruno-sm/mupdf-sys
Caused by:
failed to update submodule `mupdf`
Caused by:
failed to update submodule `thirdparty/curl`
Caused by:
invalid url `../thirdparty-curl.git`: relative URL without a base
这表明未指定 MuPDF 存储库的基本 URL,但它在文件 .git/modules/mupdf/config 中
[remote "origin"]
url = git://git.ghostscript.com/mupdf.git
fetch = +refs/heads/*:refs/remotes/origin/*
用git clone --recursive https://github.com/bruno-sm/mupdf-sys克隆仓库没有问题,所以不知道问题出在哪里。
要重现错误,您必须使用cargo new project_name 创建一个新项目,添加
[dependencies]
mupdf-sys = {git = "https://github.com/bruno-sm/mupdf-sys.git"}
到 Cargo.toml 文件并运行 cargo build。
要查看 MuPDF 存储库的内容,您可以使用 git clone --recursive git://git.ghostscript.com/mupdf.git
【问题讨论】:
-
欢迎来到 Stack Overflow!请查看如何创建minimal reproducible example,然后查看edit 您的问题以包含它。目前,尚不清楚文件、存储库的设置究竟是什么,哪些链接在哪里,什么是子模块等。理想情况下,提供一个命令行调用列表,以重新创建您的设置和错误。
-
布鲁诺,你找到解决这个问题的方法了吗?我也面临同样的问题。
-
不,对不起,我放弃了。
-
我想知道 1.5 年后是否仍然如此?我面临同样的问题,可以想象其他人使用货物并拥有相关的子模块(例如使用 GitLab 时)。
标签: git rust git-submodules rust-cargo