2.2 Mac

2.2.1 Get R

Get R > 3.3.0.

2.2.2 Get Rust

Checkout https://www.rust-lang.org/downloads.html

curl -sSf https://static.rust-lang.org/rustup.sh | sh

One of Stable, Beta, or Nightly version of Rust is OK.

You can put Rust installation in path or set CARGO_HOME environment variable to the path of cargo binary.

If you are using RStudio, you may need to follow the steps below to get the PATH ready:

  1. On launching RStudio from Finder you will notice that it will not get it’s environment from ~/.bashrc or ~/.zshrc. Instead, it will get it’s environment variables from system-wide settings.
  2. To verify, launch RStudio from Finder and type system("echo $PATH"). Then compare by typing echo $PATH in your terminal.
  3. In order to mitigate this, create a start-up initialization script to load your environment variables as configured in ~/.bashrc or ~/.zshrc : touch ~/.Renviron | R_PATH="PATH=$PATH" | echo $R_PATH > ~/.Renviron
  4. Restart RStudio and verify again by typing system("echo $PATH") at command prompt.

2.2.3 Get rustinr

Run This in R:

install.packages("devtools")
devtools::install_github("rustr/rustinr")

2.2.4 Get Xcode Command Line Tools

Open Terminal, and run git or clang, It may show a message to get you started.

Or you can check this great guide.

And we are ready to play!

Run this in R console.

library(rustinr)

rust(code ='
// #[rustr_export]
pub fn say_hi() -> String{
    "Hello World".into()
}
')

say_hi()
#> [1] "Hello World"

If some errors show up, run rustr_check to get more info:

rustr_check(detail = T)

2.2.5 Get gfortran (optional)

if ld: library not found for -lgfortran show up when you run rust(code = 'some code') .

curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2;
sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /

For more detail, see Rcpp, RcppArmadillo and OS X Mavericks “-lgfortran” and “-lquadmath” error.