# Run an artifact with a dependency on a file as a run step

**URL:** <https://ziggit.dev/t/run-an-artifact-with-a-dependency-on-a-file-as-a-run-step/17860>\
**Category:** Help\
**Tags:** build-system\
**Created:** [October 5, 2026, 8:29pm UTC](https://ziggit.dev/t/run-an-artifact-with-a-dependency-on-a-file-as-a-run-step/17860 "2026-10-05T20:29:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexandreBlais42](https://ziggit.dev/user_avatar/ziggit.dev/alexandreblais42/32/5835_2.png) [@AlexandreBlais42](https://ziggit.dev/u/AlexandreBlais42)\
**Post date:** [October 5, 2026, 8:29pm UTC](https://ziggit.dev/t/run-an-artifact-with-a-dependency-on-a-file-as-a-run-step/17860/1 "2026-10-05T20:29:43Z")

</div>

Hi, I’m working on upgrading a [program] packaged([https://codeberg.org/AlexBlais/stlink](https://codeberg.org/AlexBlais/stlink)) with Zig 0.16.0 to Zig 0.17.0.

To compile the `st-flash` program, you used to be required to define a macro that has the path to a `chips` directory which contains information needed to flash a microcontroller properly. I used to use `b.install_prefix` in the Zig 0.16.0 version. I wasn’t able to do something similar in the Zig 0.17.0, I’m guessing it’s caused by the maker and configurer process separation which makes the install prefix not known at configure time.

Luckily, the original stlink project added a [commit](https://github.com/stlink-org/stlink/commit/56ce17edb3b1b1bf2be8cacd940e05afb0d2ec11) to make it resolve that directory at runtime (it looks at `../share/other/stuff/chips` which solves my usecase.

However, I’m running into another issue. My package also exposes the compiled artifact so it can be used as part of a build step like so:

```zig
const stlink_dep = b.dependency("stlink", .{ .optimize = .safe });
const stflash = stlink_dep.artifact("st-flash");

const flash_mcu = b.addRunArtifact(stflash);
flash_mcu.addArg("write");
flash_mcu.addFileArg(firmware);
flash_mcu.addArg("0x08000000");

```

This used to work correctly, but now, the program fails to find it’s required `chips` directory.  
I’ve tracked down the issue to the `Build.addInstallDirectory` function which is used to install the `chips` from the source to `prefix/share/...`.  
In Zig 0.16.0, that directory used to be installed in `.zig-cache/i/...` and the `st-flash` executable could find it because it had it’s absolute path.  
In Zig 0.17.0, that directory is installed in the prefix and the executable is at `.zig-cache/o/{hash}/st-flash` and so cannot find the `chips` directory with the usual relative path.

So it comes down to this: How can I run a compiled artifact that has a dependency on a directory with a fixed relative path to that artifact? I’d also prefer if it didn’t pollute the installed files of the main project.

Thanks!
