---
title: "Rust Wasix Usage"
description: "Currenly, Wasix is only supported by the Wasmer runtime. So, you need to install the Wasmer runtime."
url: "https://wasix.org/docs/language-guide/rust/usage/"
markdown: "https://wasix.org/docs/language-guide/rust/usage.md"
---

# Rust Wasix Usage

> 📦
>
> Currenly, Wasix is only supported by the Wasmer runtime. So, you need to install the [Wasmer ](https://wasmer.io/) runtime.

## `cargo wasix`

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

### Running a binary

```shell
$ cargo wasix run
```

### Testing a binary

```shell
$ cargo wasix test
```

### Building a binary

```shell
$ cargo wasix build
```

### Benchmarking a binary

```shell
$ 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,`:

```shell
$ 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:

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

See Wasmer’s [runtime flags ](https://docs.wasmer.io/ecosystem/wasmer/usage) 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

```shell
$ cargo wasix init
```

Writes the [WASIX registry](https://wasix.org/docs/language-guide/rust/patched-repos.md) 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 ](https://docs.wasmer.io/ecosystem/wasmer/usage)

### The WASIX Registry

> 📦
>
> Crates that need WASIX-specific patches resolve automatically through the [WASIX registry](https://wasix.org/docs/language-guide/rust/patched-repos.md) — no `[patch.crates-io]` entries required.

---

[Documentation index](https://wasix.org/llms.txt) · [HTML version](https://wasix.org/docs/language-guide/rust/usage/)
