Rust for R Developers

Cascadia R Conference, 2025

Authors

Josiah Parry

Mossa Merhi Reimert, PhD

Published

June 20, 2025

Get set up

Before we can start, we need to get our house in order. We need to install:

Install R

Please install R version 4.5 to ensure that everyone developing has the same experience.

I recommend using rig to install a new version of R for you.

Installation instructions for rig here

Install Positron

Download the appropriate Positron installer from the downloads page.

Open the extensions pane (or press shift + cmd + x).

  • search for rust analyzer and install
  • search for even better toml and install

Install rust

To install Rust, please use rustup. If you use a system installation via brew, apt, dnf, etc you will likely run into issues. I will be able to help debug these.

For installing Rust on Mac / Unix / Linux please run:

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

Windows

If using Windows download the appropriate installer. Then, once your installation is complete, from your command prompt run:

rustup target add x86_64-pc-windows-gnu

This is a compilation target that is required for building extendr packages on Windows.

Install {rextendr}

We will be using the rextendr package to build Rust powerd R-packages.

Other R package dependencies

We also will be relying on other packages in the R ecosytem to make developing easier. Please install:

install.packages(c("devtools", "usethis"))

Install the package using:

if (!requireNamespace("remotes")) {
    install.packages("remotes")
}

remotes::install_github("extendr/rextendr")

Once rextendr is installed, run the below command. You are good to go if:

  • ✅ cargo version is printed (should be 1.80 or greater)
  • ✅ rustup has a recent version printed
  • ✅ You have an active default toolchain

If you’re using windows ensure that x86_64-pc-windows-gnu is your default target. See the above command if it is not.

R does not support packages compiled with Microsoft Visual C++ (MSVC) so this is required.

rextendr::rust_sitrep()
Rust infrastructure sitrep:
✔ "rustup": 1.27.1 (2024-04-24)
✔ "cargo": 1.87.0 (99624be96 2025-05-06)
ℹ host: aarch64-apple-darwin
ℹ toolchains: stable-aarch64-apple-darwin (default) and
  nightly-2023-07-27-aarch64-apple-darwin
ℹ target: aarch64-apple-darwin