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

Errors adding a dependency to a new project #9

Open
itowlson opened this issue Nov 13, 2024 · 3 comments
Open

Errors adding a dependency to a new project #9

itowlson opened this issue Nov 13, 2024 · 3 comments

Comments

@itowlson
Copy link
Contributor

itowlson commented Nov 13, 2024

Unexpected character '/' after patch version number (fixed)

Created a new Spin project using the http-rust template then tried to add a dependency to it, but I got a cryptic error:

$ spin deps add ~/github/wasi-key-value-sample/qr-generator-cached/target/wasm32-unknown-unknown/release/qr_generator_cached.wasm
Select packages to import (use space to select, enter to confirm): example:[email protected]
Select one or all interfaces to import from package 'example:[email protected]': qr
Select a component to add the dependency to: deps-plugin-test
Error: unexpected character '/' after patch version number

A .wit directory was created with the right tree underneath it, and deps.wit looks reasonable, but nothing was added to spin.toml.

World contains different number of imports than expected

I am not sure if this is related or a different error or related, but when I then tried to add a second component, I got a different error:

$ spin deps add ~/testing/vscode-wasm-component-model-sample/calculator-impl/target/wasm32-unknown-unknown/release/calculator_impl.wasm 
Select packages to import (use space to select, enter to confirm): vscode:example
Select one or all interfaces to import from package 'vscode:example': types
Select a component to add the dependency to: deps-plugin-test
Error: failed to merge package `root:component` into existing copy

Caused by:
    0: failed to merge world `dependency-world`
    1: world contains different number of imports than expected

This second component was not added to deps.wit (or to spin.toml).

@itowlson
Copy link
Contributor Author

If I do the same two dependencies the other way round, the first (calculator) succeeds, but the second (QR) fails. The failure on the second has the "different number of imports" message (not the "patch version number" it had when it was going first).

My guess is that there is some issue with merging WITs. So a second dep always fails at the first hurdle. But that the "patch version" error happens only in the spin.toml phase, by which time the WIT has already been written.

(As Karthik has noted, this was written as an experiment. So it totally makes sense that managing these kinds of errors and partial failures wasn't a priority. But even in experimental stage, it's so good that we are recommending it in blogs (and I've had people asking me why it's not in the docs). So we maybe need to plan on investing in it, and specifically in its failure modes...!)

@itowlson
Copy link
Contributor Author

itowlson commented Nov 13, 2024

I think the error with the qr dep may be that it imports the wasi:keyvalue interface and we don't know what to do with that? I was wrong.

@itowlson
Copy link
Contributor Author

Okay the issue with the qr dep is that the interface is versioned. The plugin currently tries to form a DependencyName from <full-package-name>/<interface-name> which in the versioned case gives us e.g. example:[email protected]/qr. This is malformed: it needs to be example:qr/[email protected]. Fix in progress.

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