naglemi
naglemi

Reputation: 85

How to set up R to run from a directory with no bin or root access?

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

Upvotes: 2

Views: 1985

Answers (1)

Katia
Katia

Reputation: 3914

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.

Upvotes: 2

Related Questions