2

I'm trying to create a self-contained R installation, that I can put on a USB or archive and share with my colleagues who don't want to go to the trouble of installing R on their computer and all the packages I have.

I did some research and found these posts:

I tried out the solutions in the 2nd and 3rd posts on my Ubuntu box, doing make install to a custom location and then either A). Using sed to edit the installed bin/R as in the second post, or B). Modifying the beginning of the installed bin/R according to the suggestion in the third post. On Ubuntu or other Linux this gives me a folder containing and installation of R's bin, lib, and share folders, which should be self-contained and can be moved about, put on USB and onto a different Ubuntu box.

I would like to achieve a similar result but for my Macbook Pro and OS X. When you make install R to a custom location with --prefix in OS X, instead of the three bin, lib, share folders you see in Linux, there is a folder called lib, and something called R.framework. The lib folder contains a folder called pkgconfig, containing a file called libR.pc. R.framework contains some symlinks and a Versions directory. This Versions directory contains a symlink called Current, and then a series of folders containing various versions of R. Each of these version folders contains a symlink called Headers, one called PrivateHeaders (containing a load of header files), and one called Resources. Finally this Resources folder contains the folders like bin, etc, share, and so on, like the R source folder.

I am unfamiliar with this OS X structure. So I would like to know, what do I need to do, now that I have make installed R to a local folder on OS X? I think in principle it should be like the fix for Linux - editing the paths in the bin/R script R_ROOT_DIR. However, I'm unfamiliar with these .framework things, in Linux you have a local folder with the three directories and it's quite simple to understand and edit the paths.

Any advice/solutions is greatly appreciated!

Thanks, Ben.

5
  • 1
    Maybe you want to look into Docker instead? Jul 9, 2015 at 20:26
  • I have considered Docker, I don't know a great amount about it - does it work for OS X? I thought it used a Linux Kernel technology. What my colleagues are asking for is for me to have my project in a single click to run solution, which requires them to not use additional software (installing R and so on). To run a docker container I suppose they would need it installed?
    – Ward9250
    Jul 9, 2015 at 20:35
  • Yes, Docker runs on OS X and Windows thanks to boot2docker. R images for Docker are provided by Rocker / Rocker on Hub. Jul 9, 2015 at 20:38
  • Take a look at cran.r-project.org/doc/manuals/r-devel/R-admin.html#Frameworks as it may help you build a portable version of the R binary for OS X.
    – hrbrmstr
    Jul 9, 2015 at 21:26
  • 1
    Not the same but similar... Cactuslab make a simple installer for ImageMagick (which can be hard to install on OSX)... may be worth a look cactuslab.com/imagemagick Jul 9, 2015 at 22:45

1 Answer 1

3

It seems as though it is possible to at least get to a start of this. After grabbing R 3.2.1 sources and untarring I did the following:

mkdir localinstall
./configure --prefix=`pwd`/localinstall \
            --without-tcltk \
            --with-cairo \
            --without-aqua \
            --without-x \
            --enable-R-shlib \
            --disable-R-framework

on a vanilla OS X system (via VMware Fusion). No other R installation was on the system.

To make it work with a .app configuration, there are environment variables in the bin/R script that you need to change.

R_HOME_DIR
R_SHARE_DIR
R_INCLUDE_DIR
R_DOC_DIR

Rscript will need some attention (the dir gets hardcoded in that binary) but you may be able to tweak this to work in side an app provided you get all the other support packages your app will use installed w/o issue.

3
  • 1
    I have done similar to this - It occurred to me that make compiles and makes working binaries and the install just puts puts stuff places in the system. So this time I have compiled, with make, but not done make install, and then used sed to remove the hardcoded paths mentioned in bin/R with environmental variables. I believe now as long as you have the environment variable set before you run it - it seems to work fine on my machine. I can't test on other OS X machines until tomorrow though.
    – Ward9250
    Jul 9, 2015 at 23:51
  • 1
    Fortunately, I believe that Rscript does actually change the dir if environmental variables are set. I read somewhere it's not well documented that it does this, but they read the source code and found it was so.
    – Ward9250
    Jul 9, 2015 at 23:52
  • @Ward9250: no it doesn't. I have tried to set R_HOME_DIR, R_SHARE_DIR and R_INCLUDE_DIR to new path and execut Rscript and it still referencing the hardcoded path only. I wonder why there is no workaround to this yet, making R installation not portable
    – GP92
    Apr 24, 2021 at 7:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .