Skip to content

use a URI-based scheme for package names like Java #20183

Closed as not planned
Closed as not planned
@andrewrk

Description

@andrewrk

Related issues:

In order to detect that two different fetched packages represent different versions of the same project, with one intended to supersede the other, we need some kind of stable identifier. Zig package management is decentralized, so there is no global namespace that serves this purpose.

We have the name field of packages, but it is not globally unique.

... or is it? This proposal takes inspiration from Java's solution to this problem which is to use the domain name system and canonical URIs, so you end up with names such as com.sun.foo.bar.ArrayList. Although Zig supports URL mirrors, canonical URIs can still be used as globally unique package identifiers.

Example fully-qualified package names would be:

  • com.github.scottredig.JavascriptBridge
  • me.andrewkelley.groovebasin
  • org.codeberg.river.river
  • org.ziglang.zig

In order to discourage people from fighting over unqualified names and causing general chaos, Zig would emit an error if a package fetched by URL was missing a top level domain name.

Whether the person owns the domain names they use is not enforced. When you choose to add a dependency on a package, you can notice whether they use their own domain name, or someone else's and factor that into the human decision of whether to trust them. Maybe someone decides to take over an abandoned project, and continue using the old maintainer's domain name for the project, for a seamless transition. If that new maintainer has built trust in the community, people would generally find this acceptable.

As for #14288, there would no longer be an id field introduced. The name field acts as the globally unique identifier that persists across versions.

As for #20178, only the last path segment in the name would be used. For example:

JavascriptBridge-1.2.3-iDYAACr46GhU
groovebasin-2.0.0-NQ8kAD5eWxrE
river-3.1.0-eTYAAFRBXp0H
zig-0.14.0-cW8vBMOZSHPt

Finally, as for #20180, this could potentially provide a way to override an entire project across the full dependency tree, to quickly find out if a particular patch, for example, could be used to make all the different usage sites of the package satisfied, thus being a candidate for a global override.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions