Skip to Content
DocumentationLanguage GuideRustUsage
WASIX / LANGUAGE GUIDE

Rust Wasix Usage

📦

Currenly, Wasix is only supported by the Wasmer runtime. So, you need to install the Wasmer  runtime.

cargo wasix

cargo wasix can be used to run, test, and build Rust programs for the Wasix

Running a binary

$ cargo wasix run

Testing a binary

$ cargo wasix test

Building a binary

$ cargo wasix build

Benchmarking a binary

$ cargo wasix bench

Passing runtime flags with -W,

run, test, and bench execute the built .wasm with the Wasmer runtime. To pass flags through to the runtime, use -W, followed by comma-separated arguments — the same idea as clang’s -Wl,:

$ cargo wasix run -W,--net $ cargo wasix run -W,--net,--volume,./tls:/tls

The first passes --net to wasmer (enabling networking); the second additionally mounts the local ./tls directory at /tls inside the sandbox. Anything after a standalone -- is forwarded to your program (or the test harness) instead of the runtime:

$ cargo wasix run -W,--net -- --port 8080

See Wasmer’s runtime flags  for what can be passed. For test and bench, cargo-wasix also applies some defaults automatically (the package directory is mounted at /project, and the host temp directory at /tmp); set CARGO_WASIX_NO_RUN_DEFAULTS=1 to disable them.

Setting up a project

$ cargo wasix init

Writes the WASIX registry config into the workspace’s .cargo/config.toml without building anything. The other commands apply the same config automatically, so running init is optional — it exists to set up (or verify) a project explicitly, e.g. before committing the config.

wasmer

wasmer-cli can also be used to run wasix binaries directly, as well as provide additional flags such as --net and --volume.

Additional flags

ℹ️

Some wasm files need extra flags that can be provided while running the file with the runtime. For example, wasmer run --net ./target/wasm32-wasmer-wasi/debug/hello.wasm. Learn more about Wasmer’s runtime flags 

The WASIX Registry

📦

Crates that need WASIX-specific patches resolve automatically through the WASIX registry — no [patch.crates-io] entries required.