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/environment@0.2.0;
  import wasi:cli/exit@0.2.0;
  import wasi:io/error@0.2.0;
  import wasi:io/streams@0.2.0;
  import wasi:cli/stdin@0.2.0;
  import wasi:cli/stdout@0.2.0;
  import wasi:cli/stderr@0.2.0;
  import wasi:clocks/wall-clock@0.2.0;
  import wasi:filesystem/types@0.2.0;
  import wasi:filesystem/preopens@0.2.0;

  export example:service/main-interface@0.1.0;
}

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/my-resource@0.1.0": target\wasm32-wasi\debug\bimpl.wasm
  "example:service/a-interface@0.1.0": target\wasm32-wasi\debug\aimpl.wasm
  "example:service/b-interface@0.1.0": 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/my-resource@0.1.0` will be imported because a dependency named `example:service/my-resource@0.1.0` could not be found
error: component `target\wasm32-wasi\debug\bimpl.wasm` is not compatible with import `example:service/b-interface@0.1.0` 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