Stream: general

Topic: with field in wit_bindgen::generate! not working


view this post on Zulip SeanOMik (Jul 27 2024 at 00:01):

I'm trying to use the macro wit_bindgen::generate! and need to use the with field to add some existing bindings. This is what I tried:

wit_bindgen::generate!({
    world: "example",

    with: {
        "lyra:api/ecs": common_api::bindings::lyra::api::ecs,
    },
});

but I get an error:

error: failed to resolve directory while parsing WIT for path [/media/data_drive/Development/Rust/lyra-wasm-scripting-test/witguest/wit]

       Caused by:
         package not found
            --> /media/data_drive/Development/Rust/lyra-wasm-scripting-test/witguest/wit/world.wit:14:9
             |
          14 |     use lyra:api/ecs.{ecs-world};
             |         ^-------

I tried to change the with to "lyra:api": common_api::bindings::lyra::api and I also got the same error. I'm not sure how I can fix it.

view this post on Zulip Pat Hickey (Jul 27 2024 at 00:07):

The lyra:api package needs to be found in a subdue of your wit/deps directory

view this post on Zulip Pat Hickey (Jul 27 2024 at 00:07):

So mkdir deps/lyraapi and stick it in there

view this post on Zulip SeanOMik (Jul 27 2024 at 00:11):

Ahh that was it! The only issue is that now I have duplicates of .wit files in my repo. I guess I could create symlinks though

view this post on Zulip SeanOMik (Jul 27 2024 at 00:11):

Thanks!


Last updated: Dec 23 2024 at 12:05 UTC