wasm-tools icon indicating copy to clipboard operation
wasm-tools copied to clipboard

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

Open andrzejressel opened this issue 11 months ago • 0 comments

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

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.

andrzejressel avatar Mar 13 '24 02:03 andrzejressel