Skip to content

Nested package ... { ... } blocks are resolved from a registry #263

Open

Description

@ashitikov

A WIT file may define packages inline with nested package ... { ... } blocks. WIT.md says they "simply provide the contents of other packages inline so that they don't have to be otherwise resolved via the filesystem or a registry". wkg resolves them from a registry anyway.

Repro with wkg 0.16.2, wit/world.wit:

package local:app@0.1.0;

package local:types@0.1.0 {
    interface t {
        type x = u32;
    }
}

world app {
    import local:types/t@0.1.0;
}

wasm-tools component wit wit accepts it. wkg fetch fails:

Error: failed to fetch dependencies for wit

Caused by:
    0: package: local:types
    1: no registry configured for namespace "local"

wkg build and wkg publish fail the same way, and so does wkg fetch in a workspace, which builds every member first. With a registry configured for the namespace, or a default registry, wkg tries to pull local:types from it instead. A path override pointing at wit does not help: the packages of the local dependency are collected again, the nested one among them.

Cause: get_packages in crates/wasm-pkg-core/src/wit.rs collects the foreign deps of the main package and of the nested ones, but does not leave out the packages the group defines itself. Fixing only that is not enough: for WIT output, populate_dependencies prints every package of the resolve except the root into deps/, the nested ones included, and the next parse fails: the package "is defined in two different locations".

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions