Getting started

To start building R packages using extendr you will need to have R and Rust toolchain installed on your machine.

Tip

Join the Discord server server to chat with other extendr users and the maintainers.

R

Ensure that you have a relatively new version of R installed. It is recommended to use a moderately new version (>= 4.2.0).

Note

Install the newest version of R from CRAN

The R package {rextendr} is used to simplify the scaffolding of extendr projects as well as document Rust functions and objects. Install the development version of {rextendr} to have the most up to date changes.

# install pak if not available
if (!requireNamespace("pak")) install.packages("pak")

# install development version of rextendr
pak::pak("extendr/rextendr")

Rust

Next, ensure that you have Rust installed. extendr has a minimum supported Rust version (msrv) of 1.64. Follow the rustup installation instructions to install Rust.

Tip

If you are using Windows, you will also need to install the stable-x86_64-pc-windows-msvc toolchain. From your terminal run the following

rustup toolchain install stable-x86_64-pc-windows-msvc
rustup default stable-x86_64-pc-windows-msvc

Once you have installed the Rust toolchain, ensure it is compatible with extendr.

From R run:

rextendr::rust_sitrep()
Rust infrastructure sitrep:
✔ "rustup": 1.26.0 (5af9b9484 2023-04-05)
✔ "cargo": 1.79.0-nightly (499a61ce7 2024-03-26)
ℹ host: aarch64-apple-darwin
ℹ toolchains: stable-aarch64-apple-darwin, nightly-aarch64-apple-darwin
  (default), and 1.64.0-aarch64-apple-darwin
ℹ targets: aarch64-apple-darwin and wasm32-unknown-unknown

If there are no issues reported by the situation report (sitrep), you are ready to start building Rust-powered R packages!


Post Script: Tools for Writing Rust

If you are new to writing Rust, this following section contains some tips.

First, it is recommended to install a configurable code editor like Visual Studio Code (VS Code).

Once you have VS Code, or another text editor, installed you will need the rust-analyzer. The rust-analyzer will provide type hinting and auto-completion suggestions. It is very helpful!