Skip to content

Ubuntu build instructions

Winston Chang edited this page Feb 19, 2014 · 2 revisions

This page tells how to install a development version of R alongside a normal installation of R. The development version can be invoked with the command RD.

These instructions are derived from the instructions on Michael Rutter's blog.

Setup

First, make sure the needed packages are installed:

sudo apt-get build-dep r-base
sudo apt-get install subversion ccache texlive texlive-fonts-extra texlive-latex-extra

Creating the RD script

As root, create a file named /usr/local/bin/RD with the following contents.

#!/bin/bash

# Setting this actually seems to cause problems, so comment out for now
# export R_LIBS_SITE=${R_LIBS_SITE-'/usr/lib/R-devel/lib/R/library:/usr/local/lib/R/site-library:/usr/lib/R/site-library::/usr/lib/R/library'}

export PATH="/usr/local/lib/R-devel/bin:$PATH"
R "$@"

Also make sure to make it executable:

sudo chmod 755 /usr/local/bin/RD

Compiling and installing R

Run these commands in the r-source directory (after cloning the r-source git repository):

# Get recommended packages if necessary
tools/rsync-recommended

R_PAPERSIZE=letter                              \
R_BATCHSAVE="--no-save --no-restore"            \
R_BROWSER=xdg-open                              \
PAGER=/usr/bin/pager                            \
PERL=/usr/bin/perl                              \
R_UNZIPCMD=/usr/bin/unzip                       \
R_ZIPCMD=/usr/bin/zip                           \
R_PRINTCMD=/usr/bin/lpr                         \
LIBnn=lib                                       \
AWK=/usr/bin/awk                                \
CC="ccache gcc"                                 \
CFLAGS="-ggdb -pipe -std=gnu99 -Wall -pedantic" \
CXX="ccache g++"                                \
CXXFLAGS="-ggdb -pipe -Wall -pedantic"          \
FC="ccache gfortran"                            \
F77="ccache gfortran"                           \
MAKE="make"                                     \
./configure                                     \
    --prefix=/usr/local/lib/R-devel             \
    --enable-R-shlib                            \
    --with-blas                                 \
    --with-lapack                               \
    --with-readline

#CC="clang -O3"                                  \
#CXX="clang++ -03"                               \


# Workaround for explicit SVN check introduced by
# https://github.com/wch/r-source/commit/4f13e5325dfbcb9fc8f55fc6027af9ae9c7750a3

# Need to build FAQ
(cd doc/manual && make front-matter html-non-svn)

rm -f non-tarball

# Get current SVN revsion from git log and save in SVN-REVISION
echo -n 'Revision: ' > SVN-REVISION
git log --format=%B -n 1 \
  | grep "^git-svn-id" \
  | sed -E 's/^git-svn-id: https:\/\/svn.r-project.org\/R\/.*?@([0-9]+).*$/\1/' \
  >> SVN-REVISION
echo -n 'Last Changed Date: ' >>  SVN-REVISION
git log -1 --pretty=format:"%ad" --date=iso | cut -d' ' -f1 >> SVN-REVISION

# End workaround

# Set this to the number of cores on your computer
make --jobs=4

sudo make install

At this point, typing RD and pressing enter should start up the newly-compiled version of R.

If the build fails and you are unable to build again, run make distclean. (You may need to run ./configure first.)

Clone this wiki locally