Skip to content

Relative git submodules did not resolve correctly #12151

Closed
@LazyGeniusMan

Description

@LazyGeniusMan

Problem

I'm trying to add dependency from git repo that have submodule from different git org/user. That submodule also have submodule as dependency. It looks something like this:

https://github.com/messense/mupdf-rs.git
└── https://github.com/ArtifexSoftware/mupdf.git
    ├── https://github.com/ArtifexSoftware/jbig2dec.git
    ├── ...
    ├── https://github.com/ArtifexSoftware/thirdparty-curl.git
    └── ...

When cargo fetch the submodule, it's using the wrong url, instead of fetching from https://github.com/ArtifexSoftware/thirdparty-curl.git, it's fetching from https://github.com/messense/thirdparty-curl.git. When I check the .gitmodules in the repo, it has relative url.

the .gitmodules looks like this:

[submodule "thirdparty/jbig2dec"]
	path = thirdparty/jbig2dec
	url = ../jbig2dec.git
...
[submodule "thirdparty/curl"]
	path = thirdparty/curl
	url = ../thirdparty-curl.git
...

Steps

  1. Run cargo new test-submodule
  2. Run cd test-submodule
  3. Run cargo add mupdf --git "https://github.com/messense/mupdf-rs.git" --rev "77f17e2b52beeeb108927f65471f122dc572740e"
  4. Run cargo build

Possible Solution(s)

No response

Notes

log:

PS C:\Users\LazyGeniusMan\Downloads\mupdf\test-toc> cargo run
    Updating git repository `https://github.com/messense/mupdf-rs.git`
    Updating git submodule `https://github.com/messense/thirdparty-curl.git`
error: failed to get `mupdf` as a dependency of package `test-toc v0.1.0 (C:\Users\LazyGeniusMan\Downloads\mupdf\test-toc)`

Caused by:
  failed to load source for dependency `mupdf`

Caused by:
  Unable to update https://github.com/messense/mupdf-rs.git?rev=77f17e2b52beeeb108927f65471f122dc572740e

Caused by:
  failed to update submodule `mupdf-sys/mupdf`

Caused by:
  failed to update submodule `thirdparty/curl`

Caused by:
  failed to fetch submodule `thirdparty/curl` from https://github.com/messense/thirdparty-curl.git

Caused by:
  failed to authenticate when downloading repository

  * attempted to find username/password via git's `credential.helper` support, but failed

  if the git CLI succeeds then `net.git-fetch-with-cli` may help here
  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
  failed to acquire username/password from local configuration

Version

cargo 1.68.2 (6feb7c9cf 2023-03-26)
release: 1.68.2
commit-hash: 6feb7c9cfc0c5604732dba75e4c3b2dbea38e8d8
commit-date: 2023-03-26
host: x86_64-pc-windows-msvc
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0-DEV (sys:0.4.59+curl-7.86.0 vendored ssl:Schannel)
os: Windows 10.0.19044 (Windows 10 Pro) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-gitArea: anything dealing with gitC-bugCategory: bugE-easyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions