# Specifying file paths for local dependencies uses system-formatted paths?

**URL:** <https://ziggit.dev/t/specifying-file-paths-for-local-dependencies-uses-system-formatted-paths/9166>\
**Category:** Help\
**Tags:** build-system\
**Created:** [March 19, 2025, 2:08pm UTC](https://ziggit.dev/t/specifying-file-paths-for-local-dependencies-uses-system-formatted-paths/9166 "2025-03-19T14:08:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsdtas](https://ziggit.dev/user_avatar/ziggit.dev/tsdtas/32/3512_2.png) [@tsdtas](https://ziggit.dev/u/tsdtas)\
**Post date:** [March 19, 2025, 2:08pm UTC](https://ziggit.dev/t/specifying-file-paths-for-local-dependencies-uses-system-formatted-paths/9166/1 "2025-03-19T14:08:48Z")

</div>

For Zig 0.14.0, adding dependencies from local file paths seems to use whatever the ‘correct’ path is for the system rather than some platform-independent representation:

`zig fetch --save ../foo/` on a linux host:

```zig
.dependencies = .{
    .foo = .{
        .url = "../foo/",
        .hash = "...",
    },
},

```

`zig fetch --save ../foo/` on a windows host:

```zig
.dependencies = .{
    .foo = .{
        .url = "..\\foo\\",
        .hash = "...",
    },
},

```

Is this intended?

---

<div class="post-metadata">

**Author:** ![pachde](https://ziggit.dev/user_avatar/ziggit.dev/pachde/32/2485_2.png) [@pachde](https://ziggit.dev/u/pachde)\
**Post date:** [March 19, 2025, 2:26pm UTC](https://ziggit.dev/t/specifying-file-paths-for-local-dependencies-uses-system-formatted-paths/9166/2 "2025-03-19T14:26:21Z")

</div>

I speculate that it’s a side-effect of the code used on Windows to ensure the exact case of the path.

The important part is does the resulting configuration work on other platforms? If not, that’s a bug.

---

<div class="post-metadata">

**Author:** ![castholm](https://ziggit.dev/user_avatar/ziggit.dev/castholm/32/1330_2.png) [@castholm](https://ziggit.dev/u/castholm)\
**Post date:** [March 19, 2025, 7:23pm UTC](https://ziggit.dev/t/specifying-file-paths-for-local-dependencies-uses-system-formatted-paths/9166/3 "2025-03-19T19:23:39Z")

</div>

`.url = "../not/an/url"` is not valid package URL. Using file URLs like in `.url = "file:///foo/bar.tar.gz"` is supposed to be supported (but there are bugs), but those can only point to tarballs, not directories, via absolute paths and are primarily meant for fetching packages on a local intranet. For build-root relative packages you use `.path = "foo/bar"`.

In addition, using `zig fetch --save filesystem/path` to add a build root-relative package not supposed to be supported. The purpose of `zig fetch` is to copy a package to Zig’s global cache to avoid needing to access the network, not to manage your `build.zig.zon`. `--save` is provided as a convenience because calculating the correct hash to put in your `build.zig.zon` by hand would be unreasonable, but it does not make sense to `--save` a package fetched by a (CWD-relative) file path as a `path` entry, because those are meant for build root-relative packages.

So for `path` entries you need to edit your `build.zig.zon` manually.

I have [an old open PR](https://github.com/ziglang/zig/pull/21931) that addresses this source of confusion and fixes the file URL bugs.

---

<div class="post-metadata">

**Author:** ![tsdtas](https://ziggit.dev/user_avatar/ziggit.dev/tsdtas/32/3512_2.png) [@tsdtas](https://ziggit.dev/u/tsdtas)\
**Post date:** [March 20, 2025, 10:08am UTC](https://ziggit.dev/t/specifying-file-paths-for-local-dependencies-uses-system-formatted-paths/9166/4 "2025-03-20T10:08:27Z")

</div>

Thank you for the detailed reply. It is appreciated. 🙂

> The purpose of `zig fetch` is to copy a package to Zig’s global cache to avoid needing to access the network, not to manage your `build.zig.zon`

Are there plans to add a CLI to manage build.zig.zon dependencies, then?

---

<div class="post-metadata">

**Author:** ![castholm](https://ziggit.dev/user_avatar/ziggit.dev/castholm/32/1330_2.png) [@castholm](https://ziggit.dev/u/castholm)\
**Post date:** [March 20, 2025, 10:29am UTC](https://ziggit.dev/t/specifying-file-paths-for-local-dependencies-uses-system-formatted-paths/9166/5 "2025-03-20T10:29:30Z")

</div>

> [@tsdtas](#):
>
> Are there plans to add a CLI to manage build.zig.zon dependencies, then?

> <https://github.com/ziglang/zig/issues/14288>
>
> Extracted from #14265.
> 
> Terminology clarification: #14307
> 
> Recognize these f…ields in build.zig.zon:
> 
> \`\`\`zig
> .{
> .id = "libsoundio-0sWAxNDvUx8gOYsk",
> .maintainer = "Andrew Kelley \<andrew@ziglang.org\>",
> .version = "3.0.0",
> }
> \`\`\`
> 
> Add subcommands for dealing with the following situations:
> \* user wants to add a new dependency
> \* user wants to remove a dependency
> \* user wants to check for updates to dependency tree
> \* user wants to update one or more dependencies
> 
> A conflict occurs when:
> \* dependency tree contains multiple projects with the same id, but different maintainer
> \* dependency tree contains multiple projects with the same id, but different version
> 
> Add conflict resolution logic. This could go one of two ways:
> \* The maximum version number is chosen but only among those projects actually referred to in the dependency tree by url/hash.
> \* User must explicitly specify how all conflicts are to be resolved whenever a conflict occurs. Conflict resolution data goes into build.zig.zon.
> - For each dependency on a project which has conflicts in the tree, user may choose that dependency to resolve to any project that exists within the dependency tree that has the same id, and a version that is greater or equal.

🙂
