Skip to content

Build failing on NetBSD due to error.NetworkUnreachable #2143

Description

@hellium6

Zig Version

0.13.0

ZLS Version

a267180

Client / Code Editor / Extensions

No response

Steps to Reproduce and Observed Behavior

  • Run NetBSD 10 and optionally setup pkgin to install from repos
  • Install zig (e.g. pkgin in zig. This currently installs 0.13.0)
  • Clone 0.13.0 release tag: git clone -b 0.13.0 https://github.com/zigtools/zls && cd zls
  • Run the build: zig build -Doptimize=ReleaseSafe

Build is failing on NetBSD for some reason. Tried the build same way on FreeBSD 14.1 amd64 (also on zig 0.13.0, same tag, same internet connection) which completed without errors.

Currently it fails with:

$ zig build -Doptimize=ReleaseSafe
install
└─ install zls
   └─ zig build-exe zls ReleaseSafe native
      └─ run zls_gen (version_data_0.13.0_20100.zig) failure
error: failed to download https://raw.githubusercontent.com/ziglang/zig/0.13.0/doc/langref.html.in: error.NetworkUnreachable
error: DownloadFailed
/usr/pkg/lib/zig/std/posix.zig:4189:29: 0x13bc30c in connect (zls_gen)
            .HOSTUNREACH => return error.NetworkUnreachable,
                            ^
/usr/pkg/lib/zig/std/net.zig:802:5: 0x12a4ee8 in tcpConnectToAddress (zls_gen)
    try posix.connect(sockfd, &address.any, address.getOsSockLen());
    ^
/usr/pkg/lib/zig/std/net.zig:787:21: 0x11da872 in tcpConnectToHost (zls_gen)
            else => return err,
                    ^
/usr/pkg/lib/zig/std/http/Client.zig:1330:37: 0x11aa449 in connectTcp (zls_gen)
        error.NetworkUnreachable => return error.NetworkUnreachable,
                                    ^
/usr/pkg/lib/zig/std/http/Client.zig:1492:14: 0x1166a55 in connect (zls_gen)
    } orelse return client.connectTcp(host, port, protocol);
             ^
/usr/pkg/lib/zig/std/http/Client.zig:1640:9: 0x113ffad in open (zls_gen)
        try client.connect(valid_uri.host.?.raw, uriPort(valid_uri, protocol), protocol);
        ^
/home/username/Repos/zls/src/config_gen/config_gen.zig:957:19: 0x113ee9d in httpGET (zls_gen)
    var request = try client.open(
                  ^
/home/username/Repos/zls/src/config_gen/config_gen.zig:835:17: 0x1149179 in generateVersionDataFile (zls_gen)
                return error.DownloadFailed;
                ^
/home/username/Repos/zls/src/config_gen/config_gen.zig:1089:13: 0x1153e95 in main (zls_gen)
            try generateVersionDataFile(gpa, version, output_path, langref_path);
            ^
error: the following command exited with error code 1:
/home/username/Repos/zls/.zig-cache/o/8f4c5105521419a31f830b7a5d73808e/zls_gen --generate-version-data 0.13.0 --generate-version-data-path /home/username/Repos/zls/.zig-cache/o/1ce592fef8b0626d84f20b8ff8b7a46e/version_data_0.13.0_20100.zig 
Build Summary: 4/8 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install zls transitive failure
   └─ zig build-exe zls ReleaseSafe native transitive failure
      └─ run zls_gen (version_data_0.13.0_20100.zig) failure
error: the following build command failed with exit code 1:
/home/username/Repos/zls/.zig-cache/o/c068b1f1d556c45489c3f87c55a305da/build /usr/pkg/bin/zig /home/username/Repos/zls /home/username/Repos/zls/.zig-cache /home/username/.cache/zig --seed 0x4c1327ef -Z530cebcc49bf1874 -Doptimize=ReleaseSafe

Expected Behavior

Complete build without errors

Relevant log output

No response

Activity

  1. techatrix commented on Jan 12, 2025

    @techatrix
    Member

    The langref.html.in file is no longer downloaded during the build phase since #2000 which resolves this issue.

    The http implementation is provided by the Zig standard library which can be tested like this:

    const std = @import("std");
    
    pub fn main() !void {
        var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .{};
        defer _ = general_purpose_allocator.deinit() == .ok;
    
        const gpa = general_purpose_allocator.allocator();
    
        var arena_allocator = std.heap.ArenaAllocator.init(gpa);
        defer arena_allocator.deinit();
    
        var client: std.http.Client = .{ .allocator = gpa };
        defer client.deinit();
        try client.initDefaultProxies(arena_allocator.allocator());
    
        var server_header_buffer: [16 * 1024]u8 = undefined;
    
        var request = try client.open(
            .GET,
            try std.Uri.parse("https://raw.githubusercontent.com/ziglang/zig/0.13.0/doc/langref.html.in"),
            .{ .server_header_buffer = &server_header_buffer },
        );
        defer request.deinit();
    
        try request.send();
        try request.finish();
        try request.wait();
    
        std.debug.print("status: {}", .{request.response.status});
    }

    This should reproduce your issue with Zig 0.13.0. If this still fails with the latest nightly build of Zig, I would suggest to open an issue with Zig.

  2. hellium6 commented on Jan 13, 2025

    @hellium6
    Author

    If this still fails with the latest nightly build of Zig, I would suggest to open an issue with Zig.

    Thanks. Will have to try that.

    In the meanwhile, for 0.13.0 on NetBSD, based on the PR, I prepared a patch that successfully builds:

    $ curl -LO https://gist.github.com/hellium6/98f4512a26b4dd0b00c975f44e4dc965/raw/541534efbecf9d29aca458ab5622116655596960/2000apply.diff
    $ git apply 2000apply.diff
    $ zig build -Doptimize=ReleaseSafe
    $ zig-out/bin/zls --version
    0.13.0
    $ uname -mrs
    NetBSD 10.0 amd64
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions