Skip to content

Step.Run.setCwd error message is confusingΒ #20793

Open

Description

@SoraTenshi

Zig Version

0.14.0-dev.339+d8f81372f

Steps to Reproduce and Observed Output

  1. Create an empty folder
  2. Paste the following code in the build.zig
const std = @import("std");

pub fn build(b: *std.Build) void {
    const call = b.addSystemCommand(&.{
        "echo",
        "test",
    });
    call.setCwd(b.path("doesnt-exist"));

    b.getInstallStep().dependOn(&call.step);
}
  1. Call zig build
  2. Observe the following output:
❯❯ zig build
install
└─ run echo failure
error: unable to spawn echo: FileNotFound
Build Summary: 0/2 steps succeeded; 1 failed
install transitive failure
└─ run echo failure
error: the following build command failed with exit code 1:
/home/nightmare/dev/.zig-cache/o/b4517676049306dd7cacdd805efe39a0/build /nix/store/bn3y3ijrvi53w3maxgphczx6np2ngj87-zig-0.14.0-dev.339+d8f81372f/bin/zig /nix/store/bn3y3ijrvi53w3maxgphczx6np2ngj87-zig-0.14.0-dev.339+d8f81372f/lib /home/nightmare/dev /home/nightmare/dev/.zig-cache /home/nightmare/.cache/zig --seed 0x873f8a98 -Z779ae0d26316a393

Expected Output

Something along the lines of:

install
└─ run echo failure
error: unable to setCwd to 'doesnt-exist': IsDirFailed

Activity

  1. added
    error messageThis issue points out an error message that is unhelpful and should be improved.
    on Jul 25, 2024
  2. added this to the unplanned milestone on Jul 26, 2024
  3. prajwalch commented on Aug 27, 2024

    @prajwalch

    This is due to the fact that there is no proper support for error payloads.

  4. Ferhunt commented on Jan 13, 2025

    @Ferhunt

    My God, this confused me as well. I kept thinking that maybe using setCwd messed up my path or something, but I hadn't realized I was messing up the path to the cwd. Though I'd like error payloads to be added I don't think this is the issue with the error, it's seems like it's just a bug.

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

    error messageThis issue points out an error message that is unhelpful and should be improved.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions