wasmerio / wapm-cli

📦 WebAssembly Package Manager (CLI)
https://wapm.io/
MIT License
372 stars 26 forks source link

Unhelpful error message when parsing `wapm.toml` fails #224

Open Michael-F-Bryan opened 2 years ago

Michael-F-Bryan commented 2 years ago

Describe the bug

The error message that gets printed when wapm can't parse a wapm.toml file give the user no way of fixing the parse error.

Given the following wapm.toml:

[package]
name = "Michael-F-Bryan/cuboid-model"
version = "0.1.0"
description = "A module for generating a cuboid."
license = "MIT or APACHE-2.0"

[[module]]
name = "cuboid-model"
source = "../target/wasm32-unknown-unknown/release/cuboid_model.wasm"
abi = "none"

Trying to publish it then says it was unable to parse the cuboid-model module, but doesn't actually say what was wrong with the module or how I can fix it.

$ wapm publish --dry-run
Error: Error building package when parsing module "cuboid-model".

Expected behavior

I would expect the wapm CLI to tell me why it was unable to build the package. In this case, the error message would probably look like:

Error: Error building package when parsing module "cuboid_model".

Caused by:
  0: Invalid "source" value
  1. The path traverses outside of the current directory

Additional context

$ wapm --version
wapm-cli 0.5.1
$ rustc --version --verbose
rustc 1.61.0-nightly (eb82facb1 2022-04-01)
binary: rustc
commit-hash: eb82facb1626166188d49599a3313fc95201f556
commit-date: 2022-04-01
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0
syrusakbary commented 2 years ago

Hey @Michael-F-Bryan , wapm currently requires the wasm files to be under the same directory or nth-child of the wapm.toml

Basically, you can have

wapm.toml
anydir/atanylevel/mymodule.wasm

Or at the base level

wapm.toml
base.wasm

But not one level below

Michael-F-Bryan commented 2 years ago

Oh yeah, I figured out what the cause of the error was. That's not an issue.

To rephrase this in a different way, if you have to go by just the error's message ("Error building package when parsing module cuboid-model"), there is no way to resolve the problem other than blindly changing your wapm.toml until it works.

syrusakbary commented 2 years ago

Yeah, you are completely right. We should return a proper error there!

JPMoresmau commented 1 year ago

I still have the same issue, in my case I'm using WAI and I tried to use a WAI file in the parent directory (bindings = { wai-version = "0.2.0", exports = "../greeter.wai" }) and it just fails with:

Error: Error building package when parsing module "english-rs".
Error: Unable to publish "english-rs"

Caused by:
    The wapm CLI exited unsuccessfully with exit code 255

The error could be clearer...