Skip to content

preview2 component cannot access --wasi-fs preopens on v0.4.0 — get-directories returns no usable preopen, ENOENT on every path (capability enabled per #392, but component FS path unwired) #405

Description

@avrabe

Summary

On kilnd v0.4.0 (fresh build), a WASI Preview 2 component cannot read, list, or open any file under a --wasi-fs preopen — every operation fails with errno::noent (os error 44), for both relative and absolute paths and for read_dir. wasi:filesystem/preopens::get-directories is invoked but yields nothing the guest can use. wasmtime, given the same directory via --dir, reads and lists it fine.

This is the still-open remainder of #392: that issue's fix correctly enabled the filesystem capability (lib.rs:1421, on --wasi-fs), but the component path is still unwired beyond the capability gate — get-directories returns no usable preopen. Filing separately since #392 is closed and the gap has now survived the v0.3.5 → v0.4.0 bump.

Reproducer

Guest (rustc --target wasm32-wasip2 -O g.rs -o g.wasm):

use std::fs;
fn main(){
  match fs::read_to_string("inside.txt"){Ok(s)=>println!("READ:{}",s.trim()),Err(e)=>println!("READ_FAIL:{}",e)}
  match fs::read_dir("."){Ok(rd)=>{let n:Vec<_>=rd.filter_map(|e|e.ok().map(|e|e.file_name().to_string_lossy().into_owned())).collect();println!("DIR:{:?}",n)},Err(e)=>println!("DIR_FAIL:{}",e)}
}
mkdir sb && echo CANARY > sb/inside.txt
( cd sb && wasmtime run --dir .::. ../g.wasm )     # READ:CANARY   DIR:["inside.txt"]
( cd sb && kilnd --wasi --component --wasi-fs . ../g.wasm )
#   READ_FAIL:No such file or directory (os error 44)
#   DIR_FAIL:No such file or directory (os error 44)
  • Both --wasi-fs . and --wasi-fs <absolute> fail identically (so it is not a relative-vs-absolute mapping issue — even read_dir of the exact preopen path fails).
  • RUST_LOG=trace shows - Filesystem paths: 1 and exactly one wasi:filesystem/preopens::get-directories call, after which the guest has no usable preopen.

Expected

kilnd --wasi --component --wasi-fs <dir> should let a preview2 component read/list files in <dir> (matching wasmtime --dir). If the component filesystem path is not yet implemented, --wasi-fs with --component should error loudly rather than silently returning ENOENT (per the repo's FAIL-LOUD rule).

Where to look

The capability is enabled and flows into the component provider (config.wasi_capabilitiesinit_wasiComponentModelProvider::new(capabilities)), and dispatcher.add_preopen(path) is called (lib.rs:571-573). But the component instance's get-directories still returns nothing usable — either the preopen is registered on a different dispatcher than the component instance queries, or the returned directory descriptor/path is not openable by the guest's WASI adapter. --fuel enforcement works on the same path (E03ED), so the component runtime itself is live.

Found via the pulseengine challenge harness (wasm32-wasip2 component FS differential vs wasmtime; fresh v0.4.0 build).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions