Skip to content

Instantly share code, notes, and snippets.

@ed-flanagan
Last active August 29, 2015 14:19
Show Gist options
  • Save ed-flanagan/6aa3f2764a9345df64cc to your computer and use it in GitHub Desktop.
Save ed-flanagan/6aa3f2764a9345df64cc to your computer and use it in GitHub Desktop.
Install R from source

Install R from source

Why not use the Aptitude package manager?

Because I find myself having to install R all the time without sudo and on systems where I can't install packages from apt-get.

So this is my "comprehensive" install script so I can pick and choose which things I need to copy-pasta to install R.

And I just keep forgetting all the flags and junk. (And I was bored/procrastinating.)

Things to do

#!/usr/bin/env bash

# Fill in R version and install dir (if wanted)
# Major version number, e.g. "3".
X=""
# Full version, e.g. "3.2.0".
VER=""
# Full path where you want to install, e.g. "/home/you/.local"
LOCAL=""

if [ -z "$X" ]; then
	echo "You need to set the major version number"
	exit 1
fi

if [ -z "$VER" ]; then
	echo "You need to set the full version value"
	exit 1
fi

# Optional apt update
sudo apt-get -y update && sudo apt-get -y upgrade \
        && sudo apt-get -y dist-upgrade && sudo apt-get -y autoremove \
        && sudo apt-get -y autoclean

# Install dependencies
# "Sections":
	# Known, From aptitude docs, Graphics (I think), Extra,
	# Unsure if needed/useful
sudo apt-get -y install \
	build-essential \
	gfortran \
	bison \
	libreadline6 \
	libreadline6-dev \
	openjdk-7-jdk \
	\
	libblas-dev \
	liblapack-dev \
	tcl8.6-dev \
	tk8.6-dev \
	groff-base \
	libncurses5-dev \
	debhelper \
	texi2html \
	texinfo \
	libbz2-dev \
	libpcre3-dev \
	zlib1g-dev \
	libpango1.0-dev \
	libtiff5-dev \
	\
	xdg-utils \
	libpng12-dev \
	libjpeg62-turbo-dev \
	libx11-dev \
	libxt-dev \
	x11proto-core-dev \
	xfonts-base \
	libcairo2-dev \
	xvfb \
	xauth \
	texlive-base \
	texlive-latex-base \
	texlive-generic-recommended \
	texlive-fonts-recommended \
	texlive-extra-utils \
	texlive-latex-recommended \
	texlive-latex-extra \
	\
    icu-devtools \
    libicu{-dev,52} \
    \
	gawk \
	linux-headers-$(uname -r) \
	flex

wget "http://cran.r-project.org/src/base/R-${X}/R-${VER}.tar.gz"
tar xzvf "R-${VER}.tar.gz"

cd "R-${VER}"

# For headless: --with-x=no
if [ ! -z "$LOCAL" ]; then
	if [ ! -d "${LOCAL}"]; then
		mkdir "${LOCAL}"
	fi
	./configure --prefix="${LOCAL}" --enable-memory-pofiling && make \
			&& make install
else
	./configure --enable-memory-profiling && make && sudo make install
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment