wac icon indicating copy to clipboard operation
wac copied to clipboard

Versioned dependencies (via `--dep`) are not found

Open itowlson opened this issue 1 year ago • 3 comments

I have the following WAC document:

package root:[email protected] targets fermyon:spin/[email protected];

let c = new root:component { ... };

export c...;

I resolve it like so:

wac resolve aaugh.wac --registry wa.dev --dep "root:component=./target/wasm32-wasi/release/calculator_spin.wasm"

And life is good. But if I change root:component to have a version:

package root:[email protected] targets fermyon:spin/[email protected];

let c = new root:[email protected] { ... };

export c...;

and invoke with the version:

wac resolve aaugh.wac --registry wa.dev --dep "root:[email protected]=./target/wasm32-wasi/release/calculator_spin.wasm"

I get:

error: failed to resolve document

  × package `root:component` does not exist in the registry
   ╭─[aaugh.wac:3:13]
 2 │ 
 3 │ let c = new root:[email protected] { ... };
   ·             ──────────┬─────────
   ·                       ╰── package `root:component` does not exist
 4 │ 
   ╰────

(If I revert the command line to the unversioned, uh, version, same error.)

Is this behaviour intentional? If so, could the error indicate more specifically what the user should do to fix it?

itowlson avatar Jul 29 '24 23:07 itowlson

This might be the relevant line that needs to be revised: https://github.com/bytecodealliance/wac/blob/main/crates/wac-resolver/src/fs.rs#L37

Some(path) if key.version.is_none() => { might need to drop the conditional requirement that version not being specified in order to use the overrides file path.

@itowlson let me know if that fixes

calvinrp avatar Jul 30 '24 14:07 calvinrp

@calvinrp Thanks for looking into that. The fix you suggest worked for me (in my one test case!). I haven't explored if it impacts anything else though - @peterhuene do you recall why you specified that condition?

itowlson avatar Jul 30 '24 20:07 itowlson

A PR could add additional test cases and document the expected usage patterns. Seems safe to do.

calvinrp avatar Jul 30 '24 20:07 calvinrp