Installing user R version on infrastructure

Summary

You want to maintain your own R packages on the infrastructure? Great! Let’s get you set up with your own R install so that you can update even the core packages whenever you need an update.

Downloading R

Visit https://ftp.osuosl.org/pub/cran/ and download the latest release (as of writing, v 3.6.1). Generally I maintain a path similar to this:

/nfs3/CGRB/home/davised/opt/downloads for downloading my source code. Your path would likely include your lab name and your own user name. This is mostly for convenience, so whatever your lab has in place works just fine.

NOTE: You’ll need to checkout a node for compiling the software, using qrsh. We don’t support compiling software on shell.cgrb.oregonstate.edu for several reasons, but mostly because we want to reduce the actual CPU utilization on the machine to make things feel responsive for everyone.

1
2
cd /nfs3/CGRB/home/davised/opt/downloads
wget https://ftp.osuosl.org/pub/cran/src/base/R-3/R-3.6.1.tar.gz

Now that you’ve downloaded the .tar.gz file, we need to extract and gunzip it.

1
2
tar axvf R-3.6.1.tar.gz
cd R-3.6.1

You should see something like this:

1
2
3
$ ls    
ChangeLog    configure     COPYING  etc      m4           Makefile.fw  po      share  SVN-REVISION  tools    VERSION-NICK
config.site  configure.ac  doc      INSTALL  Makeconf.in  Makefile.in  README  src    tests         VERSION

Now we need to configure the install with an appropriate PREFIX

1
2
./configure --prefix=/nfs3/CGRB/home/davised/opt/R/3.6.1
make

The make step will take some time. After make finishes, you can look in the bin dir just to make sure R and Rscript are there as expected.

Then:

1
make install

If you set up your path in a similar way, you can add $PREFIX/bin to your $PATH and then have immediate access to all of the custom user installs that you compile yourself.

For R specifically, the program will install to $PREFIX/R/3.6.1/bin so you’ll have to add $PREFIX/R/3.6.1/bin to your $PATH. Choose the appropriate command from below (bash or tcsh).

1
2
echo 'export PATH=/nfs3/CGRB/home/davised/opt/R/3.6.1/bin:${PATH}' >> ~/.bashrc
echo 'setenv PATH /nfs3/CGRB/home/davised/opt/R/3.6.1/bin:${PATH}' >> ~/.cshrc

Last, we just need to set our $R_LIBS to the correct directory.

1
2
echo 'export R_LIBS=/nfs3/CGRB/home/davised/opt/R/3.6.1/lib64/R/library' >> ~/.bashrc
echo 'setenv R_LIBS /nfs3/CGRB/home/davised/opt/R/3.6.1/lib64/R/library' >> ~/.cshrc

Now logout and back in and you should be good to go!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# davised:Linux @ waterman in ~ [11:26:48] 
$ R --version
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.

Let’s make sure we can install a new package

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# davised:Linux @ waterman in ~ [11:26:05] C:1
$ Rscript -e 'install.packages("remotes", repos="https://ftp.osuosl.org/pub/cran")'
trying URL 'https://ftp.osuosl.org/pub/cran/src/contrib/remotes_2.1.0.tar.gz'
Content type 'application/x-gzip' length 131622 bytes (128 KB)
==================================================
downloaded 128 KB

* installing *source* package remotes ...
** package remotes successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (remotes)

The downloaded source packages are in
	/tmp/Rtmp8edU3e/downloaded_packages
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
1
2
3
# davised:Linux @ waterman in ~ [11:28:31] 
$ ls /nfs3/CGRB/home/davised/opt/R/3.6.1/lib64/R/library/ -ltrh | tail -n1
drwxr-xr-x  7 davised cgrb 13 Nov  7 10:51 remotes