GraalVM provides a GNU-compatible R runtime to run R programs directly or in the REPL mode. It can run R code at unparalleled performance, and seamlessly integrates with the GraalVM ecosystem. The project name behind GraalVM’s R runtime development is FastR.
The GraalVM R runtime is an experimental GraalVM component.
The R language runtime is not provided by default, and can be added to GraalVM with the GraalVM Updater,
gu install r
After this step, the
Rscript launchers will become available in the
The R language home directory, which will be further referenced as
$R_HOME, is located in:
jre/languages/Rin JDK8-based GraalVM distributions
languages/Rin JDK11-based GraalVM distributions
GraalVM’s R runtime requires the OpenMP runtime library. The following commands should install this dependency:
apt-get install libgomp1
yum install libgomp
libgompshould be already installed
As of version 20.1.0 and later, GraalVM’s R runtime on Linux supports and bundles the GFortran version 3 runtime libraries. On macOS it bundles and supports the GFortran version 8.3.0 runtime libraries. It is not necessary to install the runtime libraries. However, note that a runtime library is only compatible with the GFortran compiler of that same library version or later.
On a Linux system,
$R_HOME/bin/configure_fastr can be used to check that the necessary libraries are installed, and if not, it will suggest how to install them.
Moreover, to install R packages that contain C/C++ or Fortran code, compilers for those languages must be present on the target system. The following packages satisfy the dependencies of the most common R packages:
apt-get install build-essential gfortran libxml2 libc++-dev
yum groupinstall 'Development Tools' && yum install gcc-gfortran bzip2 libxml2-devel
brew install gcc
Note: If the
gfortran executable is not on your system path, you will need to configure
the full path to it in
The default R library location is within the GraalVM installation directory.
In order to allow installation of additional packages for users who do not have write access to the GraalVM installation directory, edit the
R_LIBS_USER variable in the
Run R code directly or in the REPL mode with the
R [polyglot options] [R options] [filename]
Rscript [polyglot options] [R options] [filename]
The GraalVM R runtime uses the same polyglot options as other GraalVM languages runtimes and the same R options as GNU R, e.g.,
--help to print the list of supported options. The most important options include:
--jvm: to enable Java interoperability
--polyglot: to enable interoperability with other GraalVM languages
--vm.Djava.net.useSystemProxies=true: to pass any options to the JVM; this will be translated to
Note: Unlike other GraalVM languages runtimes, R does not yet ship with a Native Image version of its runtime.
--native option, which is the default, will still start
Rscript on top of the JVM,
but for the sake of future compatibility the Java interoperability will not be available in this case.
You can optionally build the native image:
gu rebuild-images R
The native launcher for R is intended only for curious users and experiments.
There are known issues and limitations. Once the native launcher is built, you can use
--jvm flag to run R again in the JVM mode.
The R language integration with the GraalVM ecosystem includes:
To start debugging R code, start the launcher with the
Rscript --inspect myScript.R
Note: The GNU-compatible debugging using, for example,
debug(myFunction), is also supported.