Hi everyone! I’m encountering this frustrating build issue. Find below my build.zig
and build.zig.zon
, but the tl;dr is whenever I have the .curl
member of the .dependencies
in build.zig.zon
, I encounter the following issue:
$ zig build run -- --host 127.0.0.1
/Users/axelpersinger/.cache/zig/p/curl-0.1.0-P4tT4ajAAABXSVzNUCk4dhXmeGpWYmqIzTlhS06-sL9V/build.zig:1:1: error: file exists in multiple modules
/Users/axelpersinger/.cache/zig/p/curl-0.1.0-P4tT4ajAAABXSVzNUCk4dhXmeGpWYmqIzTlhS06-sL9V/build.zig:1:1: note: root of module root.@dependencies.curl-0.1.0-P4tT4ajAAABXSVzNUCk4dhXmeGpWYmqIzTlhS06-sL9V
/Users/axelpersinger/.cache/zig/p/curl-0.1.0-P4tT4ajAAABXSVzNUCk4dhXmeGpWYmqIzTlhS06-sL9V/build.zig:1:1: note: root of module root.@dependencies.122057495ccd5029387615e6786a56626a88cd39614b4ebeb0bf559989c16fe47a3f
build.zig
:
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "http-req",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("curl", b.dependency("curl", .{}).module("curl"));
exe.root_module.addImport("nexlog", b.dependency("nexlog", .{}).module("nexlog"));
exe.root_module.addImport("simargs", b.dependency("zigcli", .{}).module("simargs"));
exe.linkLibC();
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const exe_unit_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_exe_unit_tests.step);
}
build.zig.zon
:
.{
.name = .curler,
.version = "1.0.0",
.fingerprint = 0x28ea6649c2db4109, // Changing this has security and trust implications.
.minimum_zig_version = "0.14.0",
.dependencies = .{
.zigcli = .{
.url = "https://github.com/jiacai2050/zigcli/archive/refs/tags/v0.2.0.zip",
.hash = "zigcli-0.2.0-ORC7jMBzAgBv4oHEUgpASOmsx8O5iG_OeQy159MIRdYs",
},
.nexlog = .{
.url = "https://github.com/chrischtel/nexlog/archive/v0.4.1.tar.gz",
.hash = "nexlog-0.4.0-AAAAAFpsAQDqBN6e0Z9qj4uc-sJ3yKtORv_cfZr_6D1k",
},
.curl = .{
.url = "https://github.com/jiacai2050/zig-curl/archive/refs/tags/v0.1.0.tar.gz",
.hash = "curl-0.1.0-P4tT4ajAAABXSVzNUCk4dhXmeGpWYmqIzTlhS06-sL9V",
},
},
.paths = .{
"build.zig",
"build.zig.zon",
"src/main.zig",
// For example...
//"LICENSE",
//"README.md",
},
}