Welcome to the new Golem Cloud Docs! 👋
Documentation
Rust Language Guide
Setup

Setup Rust

Creating Golem components in Rust requires installing the latest stable compiler, enabling the WASM target and installing the supported version of cargo-component.

Installing Rust

Use the official guide (opens in a new tab) to install the latest stable version of the Rust compiler.

For MacOS the recommended way is using rustup by running the following installation script:

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Enabling WebAssembly targets

With rust and rustup installed, the next step is to enable the WebAssembly support by running:

$ rustup target add wasm32-wasip1

To verify if this step was successful, run:

$ rustup target list --installed | grep wasm32-wasip1
wasm32-wasip1

Installing cargo-component

The last step is installing the cargo-component extension for Rust's cargo build tool. This will enable a set of subcommands for cargo which allows compiling Rust projects into WebAssembly components, which are ready to be uploaded to Golem.

⚠️

Golem requires a specific version of cargo-component. Please make sure the correct version is installed with the commands described below.

Install the version 0.20.0 of cargo-component with cargo itself:

$ cargo install --force --locked cargo-component@0.20.0

Verify that the correct version is installed:

$ cargo component --version
cargo-component-component 0.20.0 (2e497ee 2025-01-07)

Please refer to the cargo-component website (opens in a new tab) for more information.