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

Could not get metadata for file when adding a directory with preopen_dir #5183

Open
cfi2017 opened this issue Oct 28, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working 📦 lib-vfs About wasmer-vfs priority-medium Medium priority issue wasix

Comments

@cfi2017
Copy link

cfi2017 commented Oct 28, 2024

Describe the bug

wasmer -vV; rustc -vV
zsh: command not found: wasmer
rustc 1.84.0-nightly (9b18a122f 2024-10-26)
binary: rustc
commit-hash: 9b18a122f769859dc00d7b2c73b03dc6a1152983
commit-date: 2024-10-26
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1

Calling preopen_dir with the current PWD causes an error:

Caused by:
wasi filesystem creation error: Could not get metadata for file "/home/<snip>": entry not found

Steps to reproduce

Calling code:

use std::env;

use wasmer::{Module, Store};
use wasmer_wasix::WasiEnv;

fn main() -> anyhow::Result<()> {
    let mut store = Store::default();
    let module = include_bytes!("../module.wasm");
    let module = Module::new(&store, &module)?;
    let current_dir = env::current_dir()?;
    WasiEnv::builder("wat")
        .preopen_dir(current_dir)?
        .run_with_store(module, &mut store)?;
    Ok(())
}

Runtime dependencies:

[dependencies]
anyhow = "1.0.90"
wasmer = { version = "5.0.0-rc.1", features = ["cranelift"] }
wasmer-wasix = "0.29.0"

module.wasm:

fn main() {
    println!("Writing some bytes");
    let bytes: Vec<u8> = vec![0x60, 0x60, 0x60];
    let file = std::fs::File::create("test.bin").unwrap();
    std::io::Write::write_all(&mut std::io::BufWriter::new(file), &bytes).unwrap();
}

Module dependencies: none

Module is compiled with cargo build --target wasm32-wasip1 --release
Code is run with cargo run --release

Expected behavior

Filesystem mount that the wasm module can access

Actual behavior

An error

Additional context

@maminrayej maminrayej self-assigned this Oct 28, 2024
@maminrayej maminrayej added 📦 lib-vfs About wasmer-vfs wasix bug Something isn't working priority-medium Medium priority issue labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📦 lib-vfs About wasmer-vfs priority-medium Medium priority issue wasix
Projects
None yet
Development

No branches or pull requests

2 participants