Zig fetch error - could not be recognized as a file path

Hi,

I want to fetch a repo from a gitlab server
cloning it with git works fine

git clone git@gitlab.the_server_of_my_choice.de:my_id/my_project.git

But if I want to fetch it with zig fetch I get

zig fetch --save git+ssh://git@gitlab.the_server_of_my_choice.de:my_id/my_project.git
error: 'git+ssh://git@git@gitlab.the_server_of_my_choice.de:my_id/my_project.git' could not be recognized as a file path (FileNotFound) or an URL (InvalidPort)

Sorry that I cannot give access to the fetched repo for testing purposes, but it is marked institution internal.

zig fetch only supports the git+https scheme, e.g. zig fetch --save git+https://gitlab.com/foo/bar.git. The Git server must also support this protocol (which I believe GitLab does, but I’m unsure if it’s also the case for self-hosted).

2 Likes

I also have this problem (internal resource, only SSH access).
Here’s the issue tracking ssh fetching:

For now I think cloning it manually and then adding it with .path = "../foo" instead of fetching it is probably the cleanest option. We tried experimenting with adding a “meta-dependency” that fetches with SSH in a seperate build.zig via addSystemCommand calls to git, but it just felt like more of a hassle to maintain that than having to clone a repository once in a blue moon.

2 Likes