Install R from Source

These instructions describe how to install R from source on a Linux server.

Install R from precompiled binaries

We recommend installing R from precompiled binaries instead, following these steps.

Step 1. Install required dependencies

  • To install the necessary build dependencies for R, you may need to enable additional repositories for third-party or source packages by running the following:

    $ sudo yum install epel-release
    $ sudo sed -i.bak "/^#.*deb-src.*universe$/s/^# //g" /etc/apt/sources.list
    $ sudo apt-get update
  • Install the build dependencies for R:

    $ sudo yum-builddep R
    $ sudo apt-get build-dep r-base
    $ sudo zypper install \
        gcc \
        gcc-c++ \
        gcc-fortran \
        readline-devel \
        xorg-x11-devel \
        liblzma5 \
        xz-devel \
        pcre-devel \
        libcurl-devel \

Step 2. Specify R version

  • Define the version of R that you want to install:

    $ export R_VERSION=3.6.1

    Available versions of R

    Versions of R that are available include:

    4.0.2, 4.0.1, 4.0.0, 3.6.3, 3.6.2, 3.6.1, 3.6.0, 3.5.3, 3.5.2, 3.5.1, 3.5.0, 3.5.0, 3.4.4, 3.4.3, 3.4.2, 3.4.1, 3.4.0, 3.3.3, 3.3.2, 3.3.1, 3.3.0, 3.2.5, 3.2.4, 3.2.3, 3.2.2, 3.2.1, 3.2.0, 3.1.3, 3.1.2, 3.1.1, 3.1.0, 3.0.3, 3.0.2, 3.0.1, 3.0.0

Step 3. Download and extract R

  • Download and extract the version of R that you want to install:

    $ curl -O${R_VERSION}.tar.gz
    $ tar -xzvf R-${R_VERSION}.tar.gz
    $ cd R-${R_VERSION}

Step 4. Build and install R

  • Build and install R by running the following commands:

    $ ./configure \
        --prefix=/opt/R/${R_VERSION} \
        --enable-memory-profiling \
        --enable-R-shlib \
        --with-blas \
    $ make
    $ sudo make install

Explanation of options:

Configuration option Description


Specifies the directory where R is installed when executing the make install command. Required for the ability to install multiple versions of R in parallel.


Required to attempt to compile support for Rprofmem() and tracemem used to measure memory use in R code.


Required to make the shared libraries known to RStudio.

--with-blas and --with-lapack

  • Not required, but are commonly included.
  • These options instruct R to use the system BLAS and LAPACK libraries, which are used to speed up certain low-level math computations (for example, multiplying and inverting matrices).
  • These libraries will not speed up R itself, but can significantly speed up the underlying code execution for linear and matrix algebra.
  • For a list of configure options, run:

    ./configure --help

    For more information, refer to the R administration manual.

Step 5. Verify R installation

  • Test that R was successfully installed by running:

    $ /opt/R/${R_VERSION}/bin/R --version

  • To ensure that R is available on the default system PATH variable, create symbolic links to the version of R that you installed:

    $ sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R
    $ sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript

We recommend installing several optional system dependencies that are used by common R packages. Additional information about installing these dependencies is provided in our documentation.

(Optional) Install multiple versions of R

If you want to install multiple versions of R on the same server, you can repeat these steps to specify, download, and install a different version of R alongside existing versions.


Problems installing R from source

If you run into problems installing R from source, you can always remove the installation directory and start over.

However, once the installation succeeds, you should never move the installation directory – in other words, always install into the final destination directory.

Problems with dependencies

If you run into problems with dependencies, make sure you are able to identify and install all of the required Linux libraries (e.g., the X11 library is commonly overlooked).

Building R from source is much easier if you are using a supported operating system that is connected to the Internet. For a list of supported operating systems, refer to our Platform Deprecation Strategy for RStudio Products and Packages documentation.