rstudio / r-builds

an opinionated environment for compiling R
GNU General Public License v3.0
101 stars 19 forks source link

Support custom installation paths for R #151

Closed glin closed 1 year ago

glin commented 1 year ago

These changes are meant to address two types of support issues we get with the precompiled R binaries:

gaborcsardi commented 1 year ago

The installation path is embedded into a couple of scripts, and unfortunately also into the Rscript binary:

root@7ef3a7a70a1e:/opt/R/devel# rg --binary /opt/R/devel
bin/Rscript: binary file matches (found "\0" byte around offset 7)

bin/R
4:R_HOME_DIR=/opt/R/devel/lib/R
5:if test "${R_HOME_DIR}" = "/opt/R/devel/lib/R"; then
19:     if [ -x "/opt/R/devel/${libnn}/R/bin/exec/R" ]; then
20:        R_HOME_DIR="/opt/R/devel/${libnn}/R"
21:     elif [ -x "/opt/R/devel/${libnn_fallback}/R/bin/exec/R" ]; then
22:        R_HOME_DIR="/opt/R/devel/${libnn_fallback}/R"
35:R_SHARE_DIR=/opt/R/devel/lib/R/share
37:R_INCLUDE_DIR=/opt/R/devel/lib/R/include
39:R_DOC_DIR=/opt/R/devel/lib/R/doc

lib/pkgconfig/libR.pc
1:rhome=/opt/R/devel/lib/R
3:rincludedir=/opt/R/devel/lib/R/include

lib/R/bin/R
4:R_HOME_DIR=/opt/R/devel/lib/R
5:if test "${R_HOME_DIR}" = "/opt/R/devel/lib/R"; then
19:     if [ -x "/opt/R/devel/${libnn}/R/bin/exec/R" ]; then
20:        R_HOME_DIR="/opt/R/devel/${libnn}/R"
21:     elif [ -x "/opt/R/devel/${libnn_fallback}/R/bin/exec/R" ]; then
22:        R_HOME_DIR="/opt/R/devel/${libnn_fallback}/R"
35:R_SHARE_DIR=/opt/R/devel/lib/R/share
37:R_INCLUDE_DIR=/opt/R/devel/lib/R/include
39:R_DOC_DIR=/opt/R/devel/lib/R/doc

lib/R/bin/Rscript: binary file matches (found "\0" byte around offset 7)

lib/R/etc/Makeconf
7:# configure  '--prefix=/opt/R/devel' '--enable-R-shlib' '--with-tcltk' '--enable-memory-profiling' '--with-x' '--with-blas' '--with-lapack' 'R_PRINTCMD=/usr/bin/lpr' 'R_PAPERSIZE=letter' 'R_BROWSER=xdg-open' 'R_PDFVIEWER=xdg-open' 'LIBnn=lib'

So relocating would mean that we need to patch the scripts, and also the binary, which is tricky. It is possible to make the path shorter in the binary, so if we make the path very long at compilation time, then we can patch the binary as well. (I haven't actually tried this in practice.)