evilpie / filepath

Get the filesystem path of a file
Apache License 2.0
12 stars 2 forks source link

fails to build using wasmtime #6

Open jtmoon79 opened 6 months ago

jtmoon79 commented 6 months ago

filepath fails to build using wasmtime. This means rust target wasm32-wasi cannot be built.

error[E0046]: not all trait items implemented, missing: `path`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/filepath-0.1.2/src/lib.rs:67:1
   |
64 |     fn path(&self) -> io::Result<PathBuf>;
   |     -------------------------------------- `path` from trait
...
67 | impl FilePath for File {
   | ^^^^^^^^^^^^^^^^^^^^^^ missing `path` in implementation

For more information about this error, try `rustc --explain E0046`.
error: could not compile `filepath` due to previous error

Reproduction

  1. recreate an Ubuntu 22 environment in docker
    docker -it ubuntu:22.04 bash
  2. install stuff
    apt update
    apt install curl wget gcc unzip xz-utils xzip
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    . ~/.cargo/env
    rustup toolchain install 1.67.1
    rustup target add wasm32-wasi
    cargo install cargo-wasi
    curl https://wasmtime.dev/install.sh -sSf | bash
    . ~/.bashrc
    wget https://github.com/evilpie/filepath/archive/refs/heads/master.zip
    unzip master.zip
    cd filepath-master
    cargo wasi test --color=always -- --color=always

    installed wasmtime-v18.0.3-x86_64-linux.tar.xz using filepath at commit a0138f046b59599c4657d32b2b6f206378d7a931

  3. result

    $ cargo wasi test --color=always -- --color=always
    info: downloading component 'rust-std' for 'wasm32-wasi'
    info: installing component 'rust-std' for 'wasm32-wasi'
       Updating crates.io index
      Compiling filepath v0.1.2 (/filepath-master)
    error[E0046]: not all trait items implemented, missing: `path`
     --> src/lib.rs:67:1
      |
    64 |     fn path(&self) -> io::Result<PathBuf>;
      |     -------------------------------------- `path` from trait
    ...
    67 | impl FilePath for File {
      | ^^^^^^^^^^^^^^^^^^^^^^ missing `path` in implementation
    
    For more information about this error, try `rustc --explain E0046`.
    error: could not compile `filepath` (lib) due to 1 previous error
    warning: build failed, waiting for other jobs to finish...
    error: could not compile `filepath` (lib test) due to 1 previous error
evilpie commented 6 months ago

Would this be possible to implement for wasmtime? Should we just return an error for missing implementations? (I personally think a build failure is more obvious)

jtmoon79 commented 6 months ago

Would this be possible to implement for wasmtime?

I think you're saying "does WASM have a concept of filepaths?". And uhh... I don't know. I skimmed the wikipedia page but I'm still not sure. Did I understand your question?

Should we just return an error for missing implementations? (I personally think a build failure is more obvious)

Good point. Yeah, it's better to just fail up front instead of later on. Having said that, I think this Issue can be closed.