Problem
Re-posted #16727 (review) here in case I don't have time to fix it.
PR #16727 fixed a regression from #16246 (1.94.0) where submodules using SCP-like URLs in .gitmodules caused cargo fetch to fail with:
invalid url `[email protected]:user/repo.git`: relative URL without a base
The fix converts SCP-like URLs to ssh:// format before passing them to Url::parse.
However, the two URL forms have different path semantics:
- In SCP-like
git@host:path/repo.git, path is relative to the user's home directory (~git/path/repo.git)
- In SSH
ssh://git@host/path/repo.git, path is absolute from root (/path/repo.git)
For like GitHub and GitLab, this doesn't really matter as they intercept the path and resolve it. But for a self-hosted git server this might be an issue after the conversion.
Steps
(In theory. I haven't yet tried)
- Set up a self-hosted git server where repos are at
~<user>/repos/foo.git (under your home directory)
- Create a git dependency with
.gitmodules containing:
[submodule "sub"]
path = sub
url = <user>@<host>:repos/foo.git
- Run
cargo fetch
- Observer that Cargo converts the URL to
ssh://<user>@<host>/repos/foo.git, which the path is absolute /repos/foo.git instead of the correct relative path ~<user>/repos/foo.git
Possible Solution(s)
Changing SourceId to support SCP-like URLs would be overkill for fixing a regression. That would be a feature request for the manifest in terms of general SCP-like URL support, which is tracked in #1851
We should focus on fixing submodule fetch failure first.
We could probably store the original URL alongside the converted one in GitSource, and use the original URL to when invoking the actual fetch. (sounds bad, right?)
Notes
No response
Version
cargo 1.96.0-nightly (90ed291a5 2026-03-05)
release: 1.96.0-nightly
commit-hash: 90ed291a50efc459e0c380d7b455777ed41c6799
commit-date: 2026-03-05
host: aarch64-apple-darwin
libgit2: 1.9.2 (sys:0.20.4 vendored)
libcurl: 8.7.1 (sys:0.4.83+curl-8.15.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Mac OS 26.3.0 [64-bit]
Problem
Re-posted #16727 (review) here in case I don't have time to fix it.
PR #16727 fixed a regression from #16246 (1.94.0) where submodules using SCP-like URLs in
.gitmodulescausedcargo fetchto fail with:The fix converts SCP-like URLs to
ssh://format before passing them toUrl::parse.However, the two URL forms have different path semantics:
git@host:path/repo.git, path is relative to the user's home directory (~git/path/repo.git)ssh://git@host/path/repo.git, path is absolute from root (/path/repo.git)For like GitHub and GitLab, this doesn't really matter as they intercept the path and resolve it. But for a self-hosted git server this might be an issue after the conversion.
Steps
(In theory. I haven't yet tried)
~<user>/repos/foo.git(under your home directory).gitmodulescontaining:cargo fetchssh://<user>@<host>/repos/foo.git, which the path is absolute/repos/foo.gitinstead of the correct relative path~<user>/repos/foo.gitPossible Solution(s)
Changing SourceId to support SCP-like URLs would be overkill for fixing a regression. That would be a feature request for the manifest in terms of general SCP-like URL support, which is tracked in #1851
We should focus on fixing submodule fetch failure first.
We could probably store the original URL alongside the converted one in GitSource, and use the original URL to when invoking the actual fetch. (sounds bad, right?)
Notes
No response
Version