evcxr_jupyter
provides Rust execution in Quarto
I recently learned that setting up Rust execution in Quarto is easy via evcxr_jupyter
.
The first thing you need to do is ensure that Rust is installed. See Install Rust.
It doesn’t hurt to run rustup update
if you have not updated in a while.
Then you can use Cargo to install relevant crate. Expect this step to take a while.
$ cargo install evcxr_jupyter
Then, if necessary, add the executable evcxr_jupyter
to PATH
. On Debian-based Linux put the following in your .bashrc
file
export PATH=$PATH:~/.cargo/bin/
and run source .bashrc
.
Then use the binary to install the Jupyter tool.
evcxr_jupyter --install
At this point it should be installed. You’ll see a Rust kernel will be available when you use jupyter notebook
and Quarto will similarly recognize Rust code in {rust}
as being executable. Start with something like a “Hello, World” example. You’ll find that in the Rust REPL you will not need to specify main {...}
.
//| echo: true
println!("Hello, World.");
You can control the code echo by using //| echo: true
and //| echo: false
near the beginning of the code block.