How can I install a new version of R in my own directory, e.g., /local/data/project/behi
.
Install R in the own directory
not-root-usersoftware installation
not-root-usersoftware installation
How can I install a new version of R in my own directory, e.g., /local/data/project/behi
.
Best Answer
The easiest way to do this is to install R from source:
The second-to-last step is the critical one. It configures R to be installed into a subdirectory of your own home directory.
To run it on Linux, macOS and similar systems, add
$HOME/R/bin
to yourPATH
. Then, shell commands likeR
andRscript
will work.On macOS, you have another alternative: build
R.app
and install it into your user's privateApplications
folder. You need to have Xcode installed to do this.You might consider giving
--prefix=$HOME
instead. That installs R at the top level of your home directory, so that theR
andRscript
binaries end up in$HOME/bin
, which is likely already in your user'sPATH
. The downside is that it makes later uninstallation harder, since R would be intermingled among your other$HOME
contents.(If this is the first thing you've installed to
$HOME/bin
, you might have to log out and back in to get this in yourPATH
, since it's often added conditionally only if$HOME/bin
exists at login time.)This general pattern applies to a large amount of Unix software you can install from source code. If the software has a
configure
script, it probably understands the--prefix
option, and if not, there is usually some alternative with the same effect.These features are common for a number of reasons. In decreasing order of likelihood, in my experience:
The safe default (
/usr/local
) is not the right$prefix
in all situations. Circumstances might dictate something else such as/usr
,/opt/$PKGNAME
, etc.Binary package building systems (RPM, DEB, PKG, Cygport...) typically build and install the package into a special staging directory, then pack that up in such a way that it expands into the desired installation location.
Your case, where you can't get
root
to install the software into a typical location, so you install into$HOME
instead.