cargo-wasi icon indicating copy to clipboard operation
cargo-wasi copied to clipboard

Granting access to files

Open ibaryshnikov opened this issue 5 years ago • 5 comments

cargo wasi run -- --dir=. currently fails, but it's pretty close to working. I found out that after removing arg("--") the above command succeeds. Is it here intentionally? https://github.com/bytecodealliance/cargo-wasi/blob/8d1ed3165b2671e9fa791e4e24bcdd5cbf955cf8/src/lib.rs#L180-L183

ibaryshnikov avatar Nov 13 '19 23:11 ibaryshnikov

Yes the -- is currently intentional to ensure that any flags make their way to the binary rather than wasmtime, but it's true that there's not great handling of --dir right now.

The thinking is that eventually using interface types we can infer --dir and other flags, but it's probably good to support flags to wasmtime itself! What do you think of something like:

$ cargo wasi run --runtime-args "--dir=." -- --flag-to-wasm

or something like that?

alexcrichton avatar Nov 14 '19 15:11 alexcrichton

Oh, I missed the point that wasm binaries may also receive args ) --runtime-args sounds great to me. To continue, is it feasible to support config file at some point? After wasi receives networking support, we would like to grant access to ports as well, and all of it reminds me of Dockerfile

ibaryshnikov avatar Nov 15 '19 20:11 ibaryshnikov

Perhaps yeah! I'd prefer to not get too fancy right out the gate though, I would prefer to avoid making too many standards since this is getting to the point where it's probably good feedback for the general set of wasmtime folks to see how the CLI experience is envisioned long-term.

alexcrichton avatar Nov 16 '19 00:11 alexcrichton

any update?

clouds56 avatar Nov 20 '20 09:11 clouds56

I ran into this today and wondered if we couldn't do what other nested applications do here: Namely allow for two different levels of -- where the first level provides arguments like --dir for Wasmtime and the second -- allows to provide arguments to the Wasm executable ran by Wasmtime.

For example:

cargo wasi run --arg-to-cargo-wasi -- --arg-to-wasmtime -- --arg-to-wasm-file

Sorry if this has already been discussed elsewhere.

Robbepop avatar Sep 23 '22 11:09 Robbepop