Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Pull module name out into its own type so we can enforce wapm2pirita's assumptions #10

Open
Michael-F-Bryan opened this issue Dec 29, 2022 · 0 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Michael-F-Bryan
Copy link
Contributor

Michael-F-Bryan commented Dec 29, 2022

On wapm.io, the adamz/quickjs package uses adamz/quickjs as its module name.

wapm.toml file
[package]
name = "adamz/quickjs"
version = "0.20210327.0"
description = "QuickJS is a small and embeddable JavaScript engine. It supports the ES2019 specification including modules, asynchronous generators and proxies."
repository = "https://github.com/saghul/wasi-lab"
homepage = "https://bellard.org/quickjs/"

[[module]]
name = "adamz/quickjs"   # <----------
source = "build/qjs.wasm"
abi = "wasi"

[module.interfaces]
wasi = "0.0.0-unstable"

[[command]]
name = "qjs"
module = "adamz/quickjs"

[[command]]
name = "quickjs"
module = "adamz/quickjs"

When wapm2pirita turns the tarball into a *.webc file, we rename the atom to just quickjs... However, the manifest still thinks it is called adamz/quickjs.

Manifest and volumes for the WEBC file according to wapm2pirita
$ wapm2pirita dump volumes bin.webc
{
  "atoms": [
    {
      "name": "quickjs",
      "offset": 1983,
      "size": 2562768
    }
  ],
  "filesystem": {
    "atom": [],
    "metadata": []
  }
}

$ wapm2pirita dump manifest bin.webc
{
  "package": {
    "wapm": {
      "name": "adamz/quickjs",
      "version": "0.20210327.0",
      "homepage": "https://bellard.org/quickjs/",
      "repository": "https://github.com/saghul/wasi-lab",
      "description": "QuickJS is a small and embeddable JavaScript engine. It supports the ES2019 specification including modules, asynchronous generators and proxies."
    }
  },
  "atoms": {
    "adamz/quickjs": {
      "kind": "https://webc.org/kind/wasm",
      "signature": "sha256:b2KmvFyPjj4SpU4uy8VnTM/hx1+R2OTdbrs/7EIqTWw="
    }
  },
  "commands": {
    "qjs": {
      "runner": "https://webc.org/runner/wasi/command@unstable_",
      "annotations": {
        "wasi": {
          "atom": "adamz/quickjs",                <-----------------
          "package": null,
          "main_args": null
        }
      }
    ...
    }
  }
}

That means anything looking up the particular atom will fail because we're looking for adamz/quickjs when we should look for quickjs. That causes things like wasmer-pack to fail downstream.

$ wasmer-pack show ~/Downloads/quickjs-0.20210327.0.tar.gz
Error: Unable to load the package

Caused by:
    Could not find file "adamz/quickjs": could not find file or directory "adamz" (os error 2)

To fix this, we should change wasmer_pack::Module's name field from a String to some sort of ModuleName type which makes sure the manifest name is valid (e.g. it is an "identifier" that doesn't contain a /).

Here are the tarball and *.webc files we were testing against:

quickjs-0.20210327.0.tar.gz
quickjs-0.20210327.0.webc.zip

@Michael-F-Bryan Michael-F-Bryan added bug Something isn't working good first issue Good for newcomers labels Dec 29, 2022
@Michael-F-Bryan Michael-F-Bryan self-assigned this Dec 30, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant