Stream: git-wasmtime

Topic: wasmtime / issue #11627 bindgen! macro WIT Package resolu...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:42):

fuzing opened issue #11627:

I'm trying to share types across packages in WIT definitions. The functionality defined in the WIT files is provided by an embedded wasmtime host (Rust). There is also a wasm guest that consumes the functionality.

I have 2 projects that consume the WIT definitions, namely:

On the guest side, the component builds fine using the following steps:

  1. cargo component bindings
  2. cargo component build --release --target wasm32-unknown-unknown

Step 1 above seems to parse the WIT files as I'd anticipate, and the resulting bindings.rs contains the definition for Bytes (2 definitions, namely scoped to: abc::types::types::Bytes and abc::compression::compression::Bytes) that can be used by the local rust code.

On the wasmtime embedded host side, the bindgen! macro seems unable to find/resolve the shared types across packages (in this case, between package abc:compression@0.1.0 and package abc:types@0.1.0, where abc:types@0.1.0 contains a type bytes that should be shared across other packages, including to the abc:compression@0.1.0 package.

I have the following file structure

  wit/package.wit
  wit/deps/types/world.wit
  wit/deps/types/types.wit
  wit/deps/compression/compression.wit
  wit/deps/compression/world.wit

My shared types WIT files look like these:

wit/deps/types/world.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import types;
}

wit/deps/types/types.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    type bytes = list<u8>;
}

Note that it's the bytes type that I need to share with (in this case) the compression package

The package attempting to access the above shared types look like these:

wit/deps/compression.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface compression {
    @since(version = 0.1.0)
    use abc:types/types@0.1.0.{bytes};

    @since(version = 0.1.0)
    use types.{compression-level, compression-type};

    @since(version = 0.1.0)
    compress: func(compression-type: compression-type, compression-level: compression-level, data: bytes) -> bytes;

    @since(version = 0.1.0)
    decompress: func(compression-type: compression-type, data: bytes) -> bytes;
}

wit/deps/world.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import abc:types/types@0.1.0;

    @since(version = 0.1.0)
    import compression;
}

On the host, the bindgen! looks like:

bindgen!({
    path: "wit/deps/compression",
    world: "imports",
});

The error coming from the compilation of the host is as follows:

   Compiling wasmtime-test v1.0.0 (/home/abc/Projects/abc-project/bin/wasmtime-test)
error: failed to resolve directory while parsing WIT for path [/home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression]

       Caused by:
           package 'abc:types@0.1.0' not found. known packages:
               abc:compression@0.1.0

                --> /home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression/compression.wit:6:9
                 |
               6 |     use fusing:types/types@0.1.0.{bytes};
                 |         ^-----------
  --> bin/wasmtime-test/src/platform_implementations/compression/compression.rs:15:1
   |
15 | / bindgen!({
16 | |     path: "wit/deps/compression",
17 | |     world: "imports",
...  |
26 | | });
   | |__^

Notes:

On the guest wasm bytecode project side, the following had to be included in the Cargo.toml file:

[package.metadata.component.target.dependencies]
"abc:compression" = { path = "../../bin/wasmtime-test/wit/deps/compression" }
"abc:types" = { path = "../../bin/wasmtime-test/wit/deps/types" }

I've tried adding these to the Cargo.toml inside the host wasmtime embedding project but to no avail (I'm guessing that the bindgen! macro doesn't use these).

Also for the guest, a single world.wit WIT file, defined as:

package component:wasm-component;

interface run {
    run: func();
}

world client {
    import abc:compression/compression@0.1.0;
    import abc:types/types@0.1.0;
    export run;
}

Is there something I'm missing for the bindgen! macro options (or for the Cargo.toml on the host side)?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:42):

fuzing added the bug label to Issue #11627.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:45):

fuzing edited issue #11627:

I'm trying to share types across packages in WIT definitions. The functionality defined in the WIT files is provided by an embedded wasmtime host (Rust). There is also a wasm guest that consumes the functionality.

I have 2 projects that consume the WIT definitions, namely:

I have the following file structure for my WIT files (WIT files are defined within the host project)

  wit/package.wit
  wit/deps/types/world.wit
  wit/deps/types/types.wit
  wit/deps/compression/compression.wit
  wit/deps/compression/world.wit

My shared types WIT files look like these:

wit/deps/types/world.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import types;
}

wit/deps/types/types.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    type bytes = list<u8>;
}

Note that it's the bytes type that I need to share with (in this case) the compression package

The package attempting to access the above shared types look like these:

wit/deps/compression.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface compression {
    @since(version = 0.1.0)
    use abc:types/types@0.1.0.{bytes};

    @since(version = 0.1.0)
    use types.{compression-level, compression-type};

    @since(version = 0.1.0)
    compress: func(compression-type: compression-type, compression-level: compression-level, data: bytes) -> bytes;

    @since(version = 0.1.0)
    decompress: func(compression-type: compression-type, data: bytes) -> bytes;
}

wit/deps/world.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import abc:types/types@0.1.0;

    @since(version = 0.1.0)
    import compression;
}

On the guest side, the component builds fine using the following steps:

  1. cargo component bindings
  2. cargo component build --release --target wasm32-unknown-unknown

Step 1 above seems to parse the WIT files as I'd anticipate, and the resulting bindings.rs contains the definition for Bytes (2 definitions, namely scoped to: abc::types::types::Bytes and abc::compression::compression::Bytes) that can be used by the local rust code.

On the wasmtime embedded host side, the bindgen! macro seems unable to find/resolve the shared types across packages (in this case, between package abc:compression@0.1.0 and package abc:types@0.1.0, where abc:types@0.1.0 contains a type bytes that should be shared across other packages, including to the abc:compression@0.1.0 package.

On the host, the bindgen! looks like:

bindgen!({
    path: "wit/deps/compression",
    world: "imports",
});

The error coming from the compilation of the host is as follows:

   Compiling wasmtime-test v1.0.0 (/home/abc/Projects/abc-project/bin/wasmtime-test)
error: failed to resolve directory while parsing WIT for path [/home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression]

       Caused by:
           package 'abc:types@0.1.0' not found. known packages:
               abc:compression@0.1.0

                --> /home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression/compression.wit:6:9
                 |
               6 |     use fusing:types/types@0.1.0.{bytes};
                 |         ^-----------
  --> bin/wasmtime-test/src/platform_implementations/compression/compression.rs:15:1
   |
15 | / bindgen!({
16 | |     path: "wit/deps/compression",
17 | |     world: "imports",
...  |
26 | | });
   | |__^

Notes:

On the guest wasm bytecode project side, the following had to be included in the Cargo.toml file:

[package.metadata.component.target.dependencies]
"abc:compression" = { path = "../../bin/wasmtime-test/wit/deps/compression" }
"abc:types" = { path = "../../bin/wasmtime-test/wit/deps/types" }

I've tried adding these to the Cargo.toml inside the host wasmtime embedding project but to no avail (I'm guessing that the bindgen! macro doesn't use these).

Also for the guest, a single world.wit WIT file, defined as:

package component:wasm-component;

interface run {
    run: func();
}

world client {
    import abc:compression/compression@0.1.0;
    import abc:types/types@0.1.0;
    export run;
}

Is there something I'm missing for the bindgen! macro options (or for the Cargo.toml on the host side)?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:47):

fuzing edited issue #11627:

I'm trying to share types across packages in WIT definitions. The functionality defined in the WIT files is provided by an embedded wasmtime host (Rust). There is also a wasm guest that consumes the functionality.

I have 2 projects that consume the WIT definitions, namely:

I have the following file structure for my WIT files (WIT files are defined within the host project)

  wit/package.wit
  wit/deps/types/world.wit
  wit/deps/types/types.wit
  wit/deps/compression/compression.wit
  wit/deps/compression/world.wit

My shared types WIT files look like these:

wit/deps/types/world.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import types;
}

wit/deps/types/types.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    type bytes = list<u8>;
}

Note that it's the bytes type that I need to share with (in this case) the compression package

The package attempting to access the above shared types look like these:

wit/deps/compression/compression.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface compression {
    @since(version = 0.1.0)
    use abc:types/types@0.1.0.{bytes};

    @since(version = 0.1.0)
    use types.{compression-level, compression-type};

    @since(version = 0.1.0)
    compress: func(compression-type: compression-type, compression-level: compression-level, data: bytes) -> bytes;

    @since(version = 0.1.0)
    decompress: func(compression-type: compression-type, data: bytes) -> bytes;
}

wit/deps/compression/world.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import abc:types/types@0.1.0;

    @since(version = 0.1.0)
    import compression;
}

On the guest side, the component builds fine using the following steps:

  1. cargo component bindings
  2. cargo component build --release --target wasm32-unknown-unknown

Step 1 above seems to parse the WIT files as I'd anticipate, and the resulting bindings.rs contains the definition for Bytes (2 definitions, namely scoped to: abc::types::types::Bytes and abc::compression::compression::Bytes) that can be used by the local rust code.

On the wasmtime embedded host side, the bindgen! macro seems unable to find/resolve the shared types across packages (in this case, between package abc:compression@0.1.0 and package abc:types@0.1.0, where abc:types@0.1.0 contains a type bytes that should be shared across other packages, including to the abc:compression@0.1.0 package.

On the host, the bindgen! looks like:

bindgen!({
    path: "wit/deps/compression",
    world: "imports",
});

The error coming from the compilation of the host is as follows:

   Compiling wasmtime-test v1.0.0 (/home/abc/Projects/abc-project/bin/wasmtime-test)
error: failed to resolve directory while parsing WIT for path [/home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression]

       Caused by:
           package 'abc:types@0.1.0' not found. known packages:
               abc:compression@0.1.0

                --> /home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression/compression.wit:6:9
                 |
               6 |     use fusing:types/types@0.1.0.{bytes};
                 |         ^-----------
  --> bin/wasmtime-test/src/platform_implementations/compression/compression.rs:15:1
   |
15 | / bindgen!({
16 | |     path: "wit/deps/compression",
17 | |     world: "imports",
...  |
26 | | });
   | |__^

Notes:

On the guest wasm bytecode project side, the following had to be included in the Cargo.toml file:

[package.metadata.component.target.dependencies]
"abc:compression" = { path = "../../bin/wasmtime-test/wit/deps/compression" }
"abc:types" = { path = "../../bin/wasmtime-test/wit/deps/types" }

I've tried adding these to the Cargo.toml inside the host wasmtime embedding project but to no avail (I'm guessing that the bindgen! macro doesn't use these).

Also for the guest, a single world.wit WIT file, defined as:

package component:wasm-component;

interface run {
    run: func();
}

world client {
    import abc:compression/compression@0.1.0;
    import abc:types/types@0.1.0;
    export run;
}

Is there something I'm missing for the bindgen! macro options (or for the Cargo.toml on the host side)?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:49):

fuzing edited issue #11627:

I'm trying to share types across packages in WIT definitions. The functionality defined in the WIT files is provided by an embedded wasmtime host (Rust). There is also a wasm guest that consumes the functionality.

I have 2 projects that consume the WIT definitions, namely:

I have the following file structure for my WIT files (WIT files are defined within the host project)

  wit/package.wit
  wit/deps/types/world.wit
  wit/deps/types/types.wit
  wit/deps/compression/compression.wit
  wit/deps/compression/world.wit

My shared types WIT files look like these:

wit/deps/types/world.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import types;
}

wit/deps/types/types.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    type bytes = list<u8>;
}

Note that it's the bytes type that I need to share with (in this case) the compression package

The package attempting to access the above shared types look like these:

wit/deps/compression/compression.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface compression {
    @since(version = 0.1.0)
    use abc:types/types@0.1.0.{bytes};

    @since(version = 0.1.0)
    use types.{compression-level, compression-type};

    @since(version = 0.1.0)
    compress: func(compression-type: compression-type, compression-level: compression-level, data: bytes) -> bytes;

    @since(version = 0.1.0)
    decompress: func(compression-type: compression-type, data: bytes) -> bytes;
}

wit/deps/compression/world.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import abc:types/types@0.1.0;

    @since(version = 0.1.0)
    import compression;
}

wit/deps/compression/types.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    enum compression-level {
        ultra-low,
        low,
        medium,
        high,
        ultra-high,
    }

    @since(version = 0.1.0)
    enum compression-type {
        zstd,
        deflate,
    }
}

On the guest side, the component builds fine using the following steps:

  1. cargo component bindings
  2. cargo component build --release --target wasm32-unknown-unknown

Step 1 above seems to parse the WIT files as I'd anticipate, and the resulting bindings.rs contains the definition for Bytes (2 definitions, namely scoped to: abc::types::types::Bytes and abc::compression::compression::Bytes) that can be used by the local rust code.

On the wasmtime embedded host side, the bindgen! macro seems unable to find/resolve the shared types across packages (in this case, between package abc:compression@0.1.0 and package abc:types@0.1.0, where abc:types@0.1.0 contains a type bytes that should be shared across other packages, including to the abc:compression@0.1.0 package.

On the host, the bindgen! looks like:

bindgen!({
    path: "wit/deps/compression",
    world: "imports",
});

The error coming from the compilation of the host is as follows:

   Compiling wasmtime-test v1.0.0 (/home/abc/Projects/abc-project/bin/wasmtime-test)
error: failed to resolve directory while parsing WIT for path [/home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression]

       Caused by:
           package 'abc:types@0.1.0' not found. known packages:
               abc:compression@0.1.0

                --> /home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression/compression.wit:6:9
                 |
               6 |     use fusing:types/types@0.1.0.{bytes};
                 |         ^-----------
  --> bin/wasmtime-test/src/platform_implementations/compression/compression.rs:15:1
   |
15 | / bindgen!({
16 | |     path: "wit/deps/compression",
17 | |     world: "imports",
...  |
26 | | });
   | |__^

Notes:

On the guest wasm bytecode project side, the following had to be included in the Cargo.toml file:

[package.metadata.component.target.dependencies]
"abc:compression" = { path = "../../bin/wasmtime-test/wit/deps/compression" }
"abc:types" = { path = "../../bin/wasmtime-test/wit/deps/types" }

I've tried adding these to the Cargo.toml inside the host wasmtime embedding project but to no avail (I'm guessing that the bindgen! macro doesn't use these).

Also for the guest, a single world.wit WIT file, defined as:

package component:wasm-component;

interface run {
    run: func();
}

world client {
    import abc:compression/compression@0.1.0;
    import abc:types/types@0.1.0;
    export run;
}

Is there something I'm missing for the bindgen! macro options (or for the Cargo.toml on the host side)?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:49):

fuzing edited issue #11627:

I'm trying to share types across packages in WIT definitions. The functionality defined in the WIT files is provided by an embedded wasmtime host (Rust). There is also a wasm guest that consumes the functionality.

I have 2 projects that consume the WIT definitions, namely:

I have the following file structure for my WIT files (WIT files are defined within the host project)

  wit/package.wit
  wit/deps/types/world.wit
  wit/deps/types/types.wit
  wit/deps/compression/compression.wit
  wit/deps/compression/world.wit

My shared types WIT files look like these:

wit/deps/types/world.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import types;
}

wit/deps/types/types.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    type bytes = list<u8>;
}

Note that it's the bytes type that I need to share with (in this case) the compression package

The package attempting to access the above shared types look like these:

wit/deps/compression/compression.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface compression {
    @since(version = 0.1.0)
    use abc:types/types@0.1.0.{bytes};

    @since(version = 0.1.0)
    use types.{compression-level, compression-type};

    @since(version = 0.1.0)
    compress: func(compression-type: compression-type, compression-level: compression-level, data: bytes) -> bytes;

    @since(version = 0.1.0)
    decompress: func(compression-type: compression-type, data: bytes) -> bytes;
}

wit/deps/compression/world.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import abc:types/types@0.1.0;

    @since(version = 0.1.0)
    import types;

    @since(version = 0.1.0)
    import compression;
}

wit/deps/compression/types.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    enum compression-level {
        ultra-low,
        low,
        medium,
        high,
        ultra-high,
    }

    @since(version = 0.1.0)
    enum compression-type {
        zstd,
        deflate,
    }
}

On the guest side, the component builds fine using the following steps:

  1. cargo component bindings
  2. cargo component build --release --target wasm32-unknown-unknown

Step 1 above seems to parse the WIT files as I'd anticipate, and the resulting bindings.rs contains the definition for Bytes (2 definitions, namely scoped to: abc::types::types::Bytes and abc::compression::compression::Bytes) that can be used by the local rust code.

On the wasmtime embedded host side, the bindgen! macro seems unable to find/resolve the shared types across packages (in this case, between package abc:compression@0.1.0 and package abc:types@0.1.0, where abc:types@0.1.0 contains a type bytes that should be shared across other packages, including to the abc:compression@0.1.0 package.

On the host, the bindgen! looks like:

bindgen!({
    path: "wit/deps/compression",
    world: "imports",
});

The error coming from the compilation of the host is as follows:

   Compiling wasmtime-test v1.0.0 (/home/abc/Projects/abc-project/bin/wasmtime-test)
error: failed to resolve directory while parsing WIT for path [/home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression]

       Caused by:
           package 'abc:types@0.1.0' not found. known packages:
               abc:compression@0.1.0

                --> /home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression/compression.wit:6:9
                 |
               6 |     use fusing:types/types@0.1.0.{bytes};
                 |         ^-----------
  --> bin/wasmtime-test/src/platform_implementations/compression/compression.rs:15:1
   |
15 | / bindgen!({
16 | |     path: "wit/deps/compression",
17 | |     world: "imports",
...  |
26 | | });
   | |__^

Notes:

On the guest wasm bytecode project side, the following had to be included in the Cargo.toml file:

[package.metadata.component.target.dependencies]
"abc:compression" = { path = "../../bin/wasmtime-test/wit/deps/compression" }
"abc:types" = { path = "../../bin/wasmtime-test/wit/deps/types" }

I've tried adding these to the Cargo.toml inside the host wasmtime embedding project but to no avail (I'm guessing that the bindgen! macro doesn't use these).

Also for the guest, a single world.wit WIT file, defined as:

package component:wasm-component;

interface run {
    run: func();
}

world client {
    import abc:compression/compression@0.1.0;
    import abc:types/types@0.1.0;
    export run;
}

Is there something I'm missing for the bindgen! macro options (or for the Cargo.toml on the host side)?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:51):

fuzing edited issue #11627:

I'm trying to share types across packages in WIT definitions. The functionality defined in the WIT files is provided by an embedded wasmtime host (Rust). There is also a wasm guest that consumes the functionality.

I have 2 projects that consume the WIT definitions, namely:

I have the following file structure for my WIT files (WIT files are defined within the host project)

  wit/package.wit
  wit/deps/types/world.wit
  wit/deps/types/types.wit
  wit/deps/compression/compression.wit
  wit/deps/compression/world.wit

My shared types WIT files look like these:

wit/deps/types/world.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import types;
}

wit/deps/types/types.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    type bytes = list<u8>;
}

Note that it's the bytes type that I need to share with (in this case) the compression package

The package attempting to access the above shared types look like these:

wit/deps/compression/compression.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface compression {
    @since(version = 0.1.0)
    use abc:types/types@0.1.0.{bytes};

    @since(version = 0.1.0)
    use types.{compression-level, compression-type};

    @since(version = 0.1.0)
    compress: func(compression-type: compression-type, compression-level: compression-level, data: bytes) -> bytes;

    @since(version = 0.1.0)
    decompress: func(compression-type: compression-type, data: bytes) -> bytes;
}

wit/deps/compression/world.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import abc:types/types@0.1.0;

    @since(version = 0.1.0)
    import types;

    @since(version = 0.1.0)
    import compression;
}

wit/deps/compression/types.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    enum compression-level {
        ultra-low,
        low,
        medium,
        high,
        ultra-high,
    }

    @since(version = 0.1.0)
    enum compression-type {
        zstd,
        deflate,
    }
}

On the guest side, the component builds fine using the following steps:

  1. cargo component bindings
  2. cargo component build --release --target wasm32-unknown-unknown

Step 1 above seems to parse the WIT files as I'd anticipate, and the resulting bindings.rs contains the definition for Bytes (2 definitions, namely scoped to: abc::types::types::Bytes and abc::compression::compression::Bytes) that can be used by the local rust code.

On the wasmtime embedded host side, the bindgen! macro seems unable to find/resolve the shared types across packages (in this case, between package abc:compression@0.1.0 and package abc:types@0.1.0, where abc:types@0.1.0 contains a type bytes that should be shared across other packages, including to the abc:compression@0.1.0 package.

On the host, the bindgen! looks like:

bindgen!({
    path: "wit/deps/compression",
    world: "imports",
});

The error coming from the compilation of the host is as follows:

   Compiling wasmtime-test v1.0.0 (/home/abc/Projects/abc-project/bin/wasmtime-test)
error: failed to resolve directory while parsing WIT for path [/home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression]

       Caused by:
           package 'abc:types@0.1.0' not found. known packages:
               abc:compression@0.1.0

                --> /home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression/compression.wit:6:9
                 |
               6 |     use abc:types/types@0.1.0.{bytes};
                 |         ^-----------
  --> bin/wasmtime-test/src/platform_implementations/compression/compression.rs:15:1
   |
15 | / bindgen!({
16 | |     path: "wit/deps/compression",
17 | |     world: "imports",
...  |
26 | | });
   | |__^

Notes:

On the guest wasm bytecode project side, the following had to be included in the Cargo.toml file:

[package.metadata.component.target.dependencies]
"abc:compression" = { path = "../../bin/wasmtime-test/wit/deps/compression" }
"abc:types" = { path = "../../bin/wasmtime-test/wit/deps/types" }

I've tried adding these to the Cargo.toml inside the host wasmtime embedding project but to no avail (I'm guessing that the bindgen! macro doesn't use these).

Also for the guest, a single world.wit WIT file, defined as:

package component:wasm-component;

interface run {
    run: func();
}

world client {
    import abc:compression/compression@0.1.0;
    import abc:types/types@0.1.0;
    export run;
}

Is there something I'm missing for the bindgen! macro options (or for the Cargo.toml on the host side)?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:54):

fuzing edited issue #11627:

I'm trying to share types across packages in WIT definitions. The functionality defined in the WIT files is provided by an embedded wasmtime host (Rust). There is also a wasm guest that consumes the functionality.

I have 2 projects that consume the WIT definitions, namely:

I have the following file structure for my WIT files (WIT files are defined within the host project)

  wit/package.wit
  wit/deps/types/world.wit
  wit/deps/types/types.wit
  wit/deps/compression/compression.wit
  wit/deps/compression/types.wit
  wit/deps/compression/world.wit

My shared types WIT files look like these:

wit/deps/types/world.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import types;
}

wit/deps/types/types.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    type bytes = list<u8>;
}

Note that it's the bytes type that I need to share with (in this case) the compression package

The package attempting to access the above shared types look like these:

wit/deps/compression/compression.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface compression {
    @since(version = 0.1.0)
    use abc:types/types@0.1.0.{bytes};

    @since(version = 0.1.0)
    use types.{compression-level, compression-type};

    @since(version = 0.1.0)
    compress: func(compression-type: compression-type, compression-level: compression-level, data: bytes) -> bytes;

    @since(version = 0.1.0)
    decompress: func(compression-type: compression-type, data: bytes) -> bytes;
}

wit/deps/compression/world.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import abc:types/types@0.1.0;

    @since(version = 0.1.0)
    import types;

    @since(version = 0.1.0)
    import compression;
}

wit/deps/compression/types.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    enum compression-level {
        ultra-low,
        low,
        medium,
        high,
        ultra-high,
    }

    @since(version = 0.1.0)
    enum compression-type {
        zstd,
        deflate,
    }
}

On the guest side, the component builds fine using the following steps:

  1. cargo component bindings
  2. cargo component build --release --target wasm32-unknown-unknown

Step 1 above seems to parse the WIT files as I'd anticipate, and the resulting bindings.rs contains the definition for Bytes (2 definitions, namely scoped to: abc::types::types::Bytes and abc::compression::compression::Bytes) that can be used by the local rust code.

On the wasmtime embedded host side, the bindgen! macro seems unable to find/resolve the shared types across packages (in this case, between package abc:compression@0.1.0 and package abc:types@0.1.0, where abc:types@0.1.0 contains a type bytes that should be shared across other packages, including to the abc:compression@0.1.0 package.

On the host, the bindgen! looks like:

bindgen!({
    path: "wit/deps/compression",
    world: "imports",
});

The error coming from the compilation of the host is as follows:

   Compiling wasmtime-test v1.0.0 (/home/abc/Projects/abc-project/bin/wasmtime-test)
error: failed to resolve directory while parsing WIT for path [/home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression]

       Caused by:
           package 'abc:types@0.1.0' not found. known packages:
               abc:compression@0.1.0

                --> /home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression/compression.wit:6:9
                 |
               6 |     use abc:types/types@0.1.0.{bytes};
                 |         ^-----------
  --> bin/wasmtime-test/src/platform_implementations/compression/compression.rs:15:1
   |
15 | / bindgen!({
16 | |     path: "wit/deps/compression",
17 | |     world: "imports",
...  |
26 | | });
   | |__^

Notes:

On the guest wasm bytecode project side, the following had to be included in the Cargo.toml file:

[package.metadata.component.target.dependencies]
"abc:compression" = { path = "../../bin/wasmtime-test/wit/deps/compression" }
"abc:types" = { path = "../../bin/wasmtime-test/wit/deps/types" }

I've tried adding these to the Cargo.toml inside the host wasmtime embedding project but to no avail (I'm guessing that the bindgen! macro doesn't use these).

Also for the guest, a single world.wit WIT file, defined as:

package component:wasm-component;

interface run {
    run: func();
}

world client {
    import abc:compression/compression@0.1.0;
    import abc:types/types@0.1.0;
    export run;
}

Is there something I'm missing for the bindgen! macro options (or for the Cargo.toml on the host side)?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 20:08):

fuzing edited issue #11627:

I'm trying to share types across packages in WIT definitions. The functionality defined in the WIT files is provided by an embedded wasmtime host (Rust). There is also a wasm guest that consumes the functionality.

I have 2 projects that consume the WIT definitions, namely:

I have the following file structure for my WIT files (WIT files are defined within the host project)

  wit/package.wit
  wit/deps/types/world.wit
  wit/deps/types/types.wit
  wit/deps/compression/compression.wit
  wit/deps/compression/types.wit
  wit/deps/compression/world.wit

My shared types WIT files look like these:

wit/deps/types/world.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import types;
}

wit/deps/types/types.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    type bytes = list<u8>;
}

Note that it's the bytes type that I need to share with (in this case) the compression package

The package attempting to access the above shared types look like these:

wit/deps/compression/compression.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface compression {
    @since(version = 0.1.0)
    use abc:types/types@0.1.0.{bytes};

    @since(version = 0.1.0)
    use types.{compression-level, compression-type};

    @since(version = 0.1.0)
    compress: func(compression-type: compression-type, compression-level: compression-level, data: bytes) -> bytes;

    @since(version = 0.1.0)
    decompress: func(compression-type: compression-type, data: bytes) -> bytes;
}

wit/deps/compression/world.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import abc:types/types@0.1.0;

    @since(version = 0.1.0)
    import types;

    @since(version = 0.1.0)
    import compression;
}

wit/deps/compression/types.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    enum compression-level {
        ultra-low,
        low,
        medium,
        high,
        ultra-high,
    }

    @since(version = 0.1.0)
    enum compression-type {
        zstd,
        deflate,
    }
}

On the guest side, the component builds fine using the following steps:

  1. cargo component bindings
  2. cargo component build --release --target wasm32-unknown-unknown

Step 1 above seems to parse the WIT files as I'd anticipate, and the resulting bindings.rs contains the definition for Bytes (2 definitions, namely scoped to: abc::types::types::Bytes and abc::compression::compression::Bytes) that can be used by the local rust code.

On the wasmtime embedded host side, the bindgen! macro seems unable to find/resolve the shared types across packages (in this case, between package abc:compression@0.1.0 and package abc:types@0.1.0, where abc:types@0.1.0 contains a type bytes that should be shared across other packages, including to the abc:compression@0.1.0 package.

On the host, I'm using bindgen! inside each Host implementation source file. For the compression host implementor, the bindgen! looks like:

bindgen!({
    path: "wit/deps/compression",
    world: "imports",
});

The error coming from the compilation of the host is as follows:

   Compiling wasmtime-test v1.0.0 (/home/abc/Projects/abc-project/bin/wasmtime-test)
error: failed to resolve directory while parsing WIT for path [/home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression]

       Caused by:
           package 'abc:types@0.1.0' not found. known packages:
               abc:compression@0.1.0

                --> /home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression/compression.wit:6:9
                 |
               6 |     use abc:types/types@0.1.0.{bytes};
                 |         ^-----------
  --> bin/wasmtime-test/src/platform_implementations/compression/compression.rs:15:1
   |
15 | / bindgen!({
16 | |     path: "wit/deps/compression",
17 | |     world: "imports",
...  |
26 | | });
   | |__^

Notes:

On the guest wasm bytecode project side, the following had to be included in the Cargo.toml file:

[package.metadata.component.target.dependencies]
"abc:compression" = { path = "../../bin/wasmtime-test/wit/deps/compression" }
"abc:types" = { path = "../../bin/wasmtime-test/wit/deps/types" }

I've tried adding these to the Cargo.toml inside the host wasmtime embedding project but to no avail (I'm guessing that the bindgen! macro doesn't use these).

Also for the guest, a single world.wit WIT file, defined as:

package component:wasm-component;

interface run {
    run: func();
}

world client {
    import abc:compression/compression@0.1.0;
    import abc:types/types@0.1.0;
    export run;
}

Is there something I'm missing for the bindgen! macro options (or for the Cargo.toml on the host side)?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 20:27):

alexcrichton commented on issue #11627:

Can you try changing:

bindgen!({
    path: "wit/deps/compression",
    world: "imports",
});

to

bindgen!({
    world: "abc:compression/imports",
});

and does that fix your issue?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 21:49):

fuzing commented on issue #11627:

It does indeed - thank you so much, and enjoy your weekend!

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 21:49):

fuzing closed issue #11627:

I'm trying to share types across packages in WIT definitions. The functionality defined in the WIT files is provided by an embedded wasmtime host (Rust). There is also a wasm guest that consumes the functionality.

I have 2 projects that consume the WIT definitions, namely:

I have the following file structure for my WIT files (WIT files are defined within the host project)

  wit/package.wit
  wit/deps/types/world.wit
  wit/deps/types/types.wit
  wit/deps/compression/compression.wit
  wit/deps/compression/types.wit
  wit/deps/compression/world.wit

My shared types WIT files look like these:

wit/deps/types/world.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import types;
}

wit/deps/types/types.wit

package abc:types@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    type bytes = list<u8>;
}

Note that it's the bytes type that I need to share with (in this case) the compression package

The package attempting to access the above shared types look like these:

wit/deps/compression/compression.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface compression {
    @since(version = 0.1.0)
    use abc:types/types@0.1.0.{bytes};

    @since(version = 0.1.0)
    use types.{compression-level, compression-type};

    @since(version = 0.1.0)
    compress: func(compression-type: compression-type, compression-level: compression-level, data: bytes) -> bytes;

    @since(version = 0.1.0)
    decompress: func(compression-type: compression-type, data: bytes) -> bytes;
}

wit/deps/compression/world.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
world imports {
    @since(version = 0.1.0)
    import abc:types/types@0.1.0;

    @since(version = 0.1.0)
    import types;

    @since(version = 0.1.0)
    import compression;
}

wit/deps/compression/types.wit

package abc:compression@0.1.0;

@since(version = 0.1.0)
interface types {
    @since(version = 0.1.0)
    enum compression-level {
        ultra-low,
        low,
        medium,
        high,
        ultra-high,
    }

    @since(version = 0.1.0)
    enum compression-type {
        zstd,
        deflate,
    }
}

On the guest side, the component builds fine using the following steps:

  1. cargo component bindings
  2. cargo component build --release --target wasm32-unknown-unknown

Step 1 above seems to parse the WIT files as I'd anticipate, and the resulting bindings.rs contains the definition for Bytes (2 definitions, namely scoped to: abc::types::types::Bytes and abc::compression::compression::Bytes) that can be used by the local rust code.

On the wasmtime embedded host side, the bindgen! macro seems unable to find/resolve the shared types across packages (in this case, between package abc:compression@0.1.0 and package abc:types@0.1.0, where abc:types@0.1.0 contains a type bytes that should be shared across other packages, including to the abc:compression@0.1.0 package.

On the host, I'm using bindgen! inside each Host implementation source file. For the compression host implementor, the bindgen! looks like:

bindgen!({
    path: "wit/deps/compression",
    world: "imports",
});

The error coming from the compilation of the host is as follows:

   Compiling wasmtime-test v1.0.0 (/home/abc/Projects/abc-project/bin/wasmtime-test)
error: failed to resolve directory while parsing WIT for path [/home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression]

       Caused by:
           package 'abc:types@0.1.0' not found. known packages:
               abc:compression@0.1.0

                --> /home/abc/Projects/abc-project/bin/wasmtime-test/wit/deps/compression/compression.wit:6:9
                 |
               6 |     use abc:types/types@0.1.0.{bytes};
                 |         ^-----------
  --> bin/wasmtime-test/src/platform_implementations/compression/compression.rs:15:1
   |
15 | / bindgen!({
16 | |     path: "wit/deps/compression",
17 | |     world: "imports",
...  |
26 | | });
   | |__^

Notes:

On the guest wasm bytecode project side, the following had to be included in the Cargo.toml file:

[package.metadata.component.target.dependencies]
"abc:compression" = { path = "../../bin/wasmtime-test/wit/deps/compression" }
"abc:types" = { path = "../../bin/wasmtime-test/wit/deps/types" }

I've tried adding these to the Cargo.toml inside the host wasmtime embedding project but to no avail (I'm guessing that the bindgen! macro doesn't use these).

Also for the guest, a single world.wit WIT file, defined as:

package component:wasm-component;

interface run {
    run: func();
}

world client {
    import abc:compression/compression@0.1.0;
    import abc:types/types@0.1.0;
    export run;
}

Is there something I'm missing for the bindgen! macro options (or for the Cargo.toml on the host side)?


Last updated: Dec 06 2025 at 07:03 UTC