Setup
Before we can start writing Rust code, we need to install a few tools.
Godot Engine
While you can write Rust code without the Godot engine, we highly recommend to install Godot for quick feedback loops. For the rest of the tutorial, we assume that you have Godot 4 installed and available either:
- in your
PATH
asgodot4
, - or an environment variable called
GODOT4_BIN
, containing the path to the Godot executable.
Godot from pre-built binaries
Binaries of Godot 4 can be downloaded from the official website.
For beta and older versions, you can also check the download archive.
Installing Godot via command-line
# --- Linux ---
# Fedora/RHEL.
dnf install godot
# Arch Linux.
pacman -Syu godot
paru -Syu godot
# Flatpak (e.g. Ubuntu, Debian, or distro-independent).
flatpak install flathub org.godotengine.Godot
# --- Windows ---
winget install -e --id GodotEngine.GodotEngine
choco install godot
scoop bucket add extras && scoop install godot
# --- macOS ---
brew install godot
If you plan to target Godot versions different from the latest stable release, please read Selecting a Godot version.
Rust
rustup is the preferred way to install the Rust toolchain. It includes the compiler, standard library, Cargo (the package manager) as well as tools like rustfmt or clippy. Visit the website to download binaries or installers for your platform. Alternatively, you can install it via command-line.
Installing rustup via command-line
# Linux (distro-independent)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Windows
winget install -e --id Rustlang.Rustup
# macOS
brew install rustup
After installation of rustup and the stable
toolchain, you can verify that they are working:
$ rustc --version
rustc 1.88.0 (6b00bc388 2025-06-23)
LLVM
This was necessary in the past due to bindgen
, which depends on LLVM.
However, we now provide pre-built artifacts, so that most users can simply add the Cargo dependency and start immediately.
This also significantly reduces initial compile times, as bindgen
was quite heavyweight with its many transitive dependencies.
You will still need LLVM if you plan to use the api-custom
feature, for example if you have a forked version of Godot or custom
modules. To just use a different API version of Godot, you do not need LLVM though; see Selecting a Godot version.
LLVM binaries can be downloaded from llvm.org. Once installed, you can check whether LLVM's clang compiler is available:
clang -v