2

I need to run the latest version of R on our server. We have an older version in the bin directory, so that simply typing R in the command line brings this up. It is set up such that:

>which R
/bin/R

Our administrators will not upgrade R at this time and I need to use the latest version. In the past, I've been able to run programs without any bin or root access by simply putting them in my directory. I can then call those programs by typing out the whole path, instead of just typing "R".

I am unable to find a method for installing R that does not involve installing it in the bin through an installer such as apt-get. Is there a way for me to install R in my own directory, as I have done for other programs, without placing it in the /bin/ folder of system-wide executables, and without admin privileges?

We are on CentOS Linux release 7.2.1511

Update: When I attempt the following, as recommended:

wget http://cran.r-project.org/src/base/R-3/R-3.5.1.tar.gz

# untar the sources
tar xzvf R-3.5.1.tar.gz
cd R-3.5.1

# configure
./configure --prefix=/path/to/your/local/dir/install --enable-R-shlib --enable-memory-profiling --enable-R-profiling --with-valgrind-instrumentation=2

I get the following error because I don't have access to the /data/ directory it default to.

checking build system type... mkdir: cannot create directory '/data/cg55281-32717': Permission denied mkdir: cannot create directory '/data/cg-55281': Permission denied config.guess: cannot create a temporary directory in /data configure: error: cannot guess build type; you must specify one

naglemi
  • 75
  • 8
  • How about installing R locally through [anaconda](https://docs.anaconda.com/anaconda/user-guide/tasks/use-r-language/)? Also perhaps worth taking a look at: [How to install R 3.2.2 using a conda environment on CentOS](https://gist.github.com/adefelicibus/2ec97b5f8f12b4d71ed749d4f15ccd73) – Maurits Evers Nov 22 '18 at 02:28
  • Apparently it is not possible to install R through anaconda when one needs R installed with the --enable-R-shlib option. – tedtoal Mar 02 '19 at 00:22

1 Answers1

2

Yes, This can be easily done as follows:

wget http://cran.r-project.org/src/base/R-3/R-3.5.1.tar.gz

# untar the sources
tar xzvf R-3.5.1.tar.gz
cd R-3.5.1

# configure
./configure --prefix=/path/to/your/local/dir/install --enable-R-shlib --enable-memory-profiling --enable-R-profiling --with-valgrind-instrumentation=2

# build R
make

# install
make install

Once you build your own version of R, set environment variables:

export PATH=/path/to/your/local/dir/install/bin:$PATH
export R_HOME=/path/to/your/local/dir/install/lib64/R

These variables need to be set every time you want to use your own version of R.

Katia
  • 3,784
  • 1
  • 14
  • 27
  • I've updated my original post to show an error I'm getting on the third step of this. – naglemi Nov 23 '18 at 01:01
  • Essentially _every_ GNU program works this way and the answer is entirely correct. But to be safe you could also set the prefix twice: once at `configure` time, and once again at `make install` time via `make DESTDIR=/path/to/your/local/dir/install install`. – Dirk Eddelbuettel Nov 23 '18 at 01:06
  • @naglemi In addition to what Dirk suggested above I would also recommend to check the permissions for the directory where you are trying to install R. It looks like you are trying to install R into a directory where you do not have permissions to write. In my answer `/path/to/your/local/dir/` must be a directory which you created. – Katia Nov 23 '18 at 15:56
  • I have read, write and execute priveledges for the local directory I am trying to install to, and I created this directory. However, I'm still getting this error because it's trying to write something to this /data/ folder which I do not have access to and did not tell it to install anything into. I don't know why it's trying to do this. I grepped the "configure" script for "/data/" and it's not in there, or in the command to call the script. – naglemi Nov 23 '18 at 21:25
  • @naglemi It looks like your latest error says that configure cannot determine build type. This is a separate error. See some suggestions here: https://stackoverflow.com/questions/4810996/how-to-resolve-configure-guessing-build-type-failure – Katia Nov 23 '18 at 21:45
  • After following the linked suggestion and modifying .configure to have the specific directory for my correct config.guess, I'm getting the same error. Worth noting the method in your answer works on a machine on which I have root access and it is able to create this /data/ folder. It isn't working on the machine I don't have root access to, however. – naglemi Nov 24 '18 at 01:58
  • @naglemi These steps work for a user with no root privileges. I have used this method many times. Those steps are listed in the R installation manual. Setting "prefix" flag is a standard practice when GNU software installed in a user-define directory with no root privileges. It's hard to help you further without knowing specifics of your system. For example do you have enough space quota to install this software? There could be many other problems that can cause errors. You should contact your system admin. – Katia Nov 24 '18 at 05:12