Workarounds for git via ssh in the Zig package manager

There is an open issue to implement SSH support for the package manager:

Until it is implemented, there’s no way to fetch packages that exist in private repositories accessible by git+ssh only. Unfortunately that includes all the codebases at my day job - and I imagine, many other companies who work on commercial closed-source software.

Currently I’m working around this by cloning the code repositories I need manually and then adding them to my build.zig.zon file like this:

.dependencies = .{
    .a= .{
        .url = "./deps/a",
        .hash = "...",
    },
    .b = .{
        .url = "./deps/b",
        .hash = "...",
    },
    // And so on... 
},

I’m starting this topic to ask the community if better methods exist, until SSH support lands. :slight_smile:

3 Likes

As a workaround, you might be able to create an ssh tunnel, and expose it locally as plain unencrypted git? Not sure if possible, but maybe worth exploring.

Something like this?

1 Like

Hello, I personally do this to link my modules into a library or modules… very practical for in-house development.

.{
    .name = .as400jplpc,
    .version = "0.0.0",
    .minimum_zig_version = "0.14.0",
    .dependencies = .{
        .libtui = .{
            .path = "../libtui",
        },
        .libznd = .{
            .path = "../libznd",
        },
        .libsql = .{
            .path = "../libsql",
        },
    },
    .paths = .{"",},
    .fingerprint = 0xbbebb3706425d0a9,
}