ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.36k stars 2.51k forks source link

`zig fetch --save` puts URL in already existing `.path` entry #21690

Open dermetfan opened 1 day ago

dermetfan commented 1 day ago

Zig Version

0.14.0-dev.1860+2e2927735

Steps to Reproduce and Observed Behavior

Given a build.zig.zon with a path dependency

.zqlite = .{ .path = "foo" },

when you fetch a URL dependency using

zig fetch --save https://github.com/karlseguin/zqlite.zig/archive/master.tar.gz

it puts the URL in the path field, resulting in an invalid dependency:

.zqlite = .{ .path = "https://github.com/karlseguin/zqlite.zig/archive/master.tar.gz", },

I'm providing a small repository so you can reproduce quickly: https://github.com/dermetfan/zig-issue-fetch-path

Expected Behavior

I believe it is reasonable for zig fetch --save to recognize this and write a valid dependency:

.zqlite = .{ .url = "https://github.com/karlseguin/zqlite.zig/archive/master.tar.gz", .hash = "<something>" },
nektro commented 1 day ago

side note, you should never use branch names in your url refs; only tags or commits. otherwise its bound to break almost immediately

dermetfan commented 1 day ago

Sure, this is just to keep the example short.