bytecodealliance / bytecodealliance/wasmtime

Consider new syntax or a new option for the `--dir` CLI option

Open
#7,309 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 19h
Merged PRs (30d)
121

Description

This issue is inspired by discussion on https://github.com/bytecodealliance/wasmtime/pull/7301 and [Zulip](https://bytecodealliance.zulipchat.com/#narrow/stream/206238-general/topic/Popular.20WASI.20runtimes.20w.2F.20a.20CLI.20for.20env.20vars.20and.20dir.20mapping.3F). To summarize a bit, the `--dir` syntax is inconsistent between Wasmtime and other runtimes, and a notable inconsistency of Wasmtime is the usage of `::` as a delimiter as opposed to a single character such as `:`. I'll also personally note that there's inconsistency with Docker which is another common tool for a similar operatin which uses `:`.

As of https://github.com/bytecodealliance/wasmtime/pull/7301 and Wasmtime 14/15 the CLI for Wasmtime will support:

* `--dir foo` - opens the host directory `foo` and mounts it in the guest as `foo`
* `--dir foo::bar` - opens the host directory `foo` and mounts it in the guest as `bar`

I find the discussion [over on Docker's documentation](https://docs.docker.com/storage/bind-mounts/) pretty illuminating here. The gist, as it applies to Wasmtime, appears to be:

* Docker's `-v` is the "old" syntax and is acknowledged to be cryptic and error-prone, and this is basically the same as the `--dir` syntax Wasmtime has today (and the subject of [this comment](https://github.com/bytecodealliance/wasmtime/pull/7301#issuecomment-1771850498))
* Docker's `--mount` is the "new" syntax which uses `--mount key=val,key2=val,key3=val` which is more verbose but more clear

While I wasn't personally present (@sunfishcode maybe you were?) when this option was originally added to Wasmtime my guess is that the choice of `::` delimiter for Wasmtime assists with Windows-style paths which have colons in them with absolute paths such as `C:\foo\bar`. Such a concern does not affect Docker, however, where Docker appears to support `docker run -v z:\foo:c:\dest ...` according to its [documentation](https://docs.docker.com/engine/reference/commandline/run/#read-only).

With all that in mind, there's a few questions in my mind of what to do with Wasmtime:

1. Should `--dir` be kept at all? Should this be replaced entirely with a separate option with more obvious syntax to readers? (albeit more verbose to writers)
2. If `--dir` is kept, can its delimiter be changed to `:` to be more consistent with Docker? If so how do Windows paths work?
3. If a new option is added, what should it be called? Additionally what should its syntax be? For Docker it's a `,`-delimited list of `key=value` pairs, but I'm also not sure how this handles paths-with-commas in them.

Personally I think that while the CLI was overhauled for Wasmtime 14 we can still perform this change when we want. It's probably not too too hard to have broad messaging of a change in syntax if `--dir` changes or gets replaced. So in that sense while we can't change anything for Wasmtime 14, I do still think changes should be considered for 15+

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.