Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"component is not compatible with import" error is returned when combining components with resources using dependencies #1452

Open
andrzejressel opened this issue Mar 13, 2024 · 0 comments

Comments

@andrzejressel
Copy link

andrzejressel commented Mar 13, 2024

Repository: https://github.com/andrzejressel/wasm-tools-compose-resources-bug-report

I have WIT structure that looks like this:

stateDiagram-v2
[*] --> main
main --> a
main --> b
a --> b
Loading

b is also implementing resource type that is used in the whole tree. Repository after compiling

cargo component build -p main -p aimpl -p bimpl

is generating main.wasm, aimpl.wasm and bimpl.wasm. Everything works fine when I combine them manually:

wasm-tools compose -o target/wasm32-wasi/debug/composed1.wasm target/wasm32-wasi/debug/main.wasm -d target/wasm32-wasi/debug/aimpl.wasm
wasm-tools compose -o target/wasm32-wasi/debug/composed2.wasm target/wasm32-wasi/debug/composed1.wasm -d target/wasm32-wasi/debug/bimpl.wasm

wasm-tools component wit target/wasm32-wasi/debug/composed2.wasm

Output:

world root {
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:io/[email protected];
  import wasi:io/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:clocks/[email protected];
  import wasi:filesystem/[email protected];
  import wasi:filesystem/[email protected];

  export example:service/[email protected];
}

However in my real project the graph will be more complicated so I've decided to try using config file. For this example it looks like this

dependencies:
#  "example:service/[email protected]": target\wasm32-wasi\debug\bimpl.wasm
  "example:service/[email protected]": target\wasm32-wasi\debug\aimpl.wasm
  "example:service/[email protected]": target\wasm32-wasi\debug\bimpl.wasm

With my-resource commented out I would expect to get single component with my-resource import and with it uncommented I'd expect single component with only wasi import. However I'm receiving following error:

> wasm-tools compose -c config.yml target\wasm32-wasi\debug\main.wasm -o output.wasm           
[2024-03-13T02:49:48Z WARN ] instance `example:service/[email protected]` will be imported because a dependency named `example:service/[email protected]` could not be found
error: component `target\wasm32-wasi\debug\bimpl.wasm` is not compatible with import `example:service/[email protected]` of component `target\wasm32-wasi\debug\main.wasm`

The same config worked fine before implementing resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant