Windows
On Windows, this seems easy. It is possible that we'll need to replace Rscript.exe, see below at macOS.
macOS
-
On macOS we can set DYLD_LIBRARY_PATH in the R startup script:
# export DYLD_PRINT_LIBRARIES=1
R_HOME_DIR=/Users/gaborcsardi/R/R-4.5.3
R_HOME_DIR="$(cd "$(dirname "$(readlink -f "$0" 2>/dev/null || realpath "$0" 2>/dev/null || echo "$0")")/.." && pwd)"
export DYLD_LIBRARY_PATH="${R_HOME_DIR}/lib"
Positron can't handle this (yet), so temporarily we'll set R_HOME_DIR to a constant first, because this is what Positron parses from the R file.
-
We'll also need to update the hardcoded paths in some script files.
-
The most hacky part is working around the install path being hardcoded into the Rscript binary. We'll need to replace that with a shell script that sets RHOME, which Rscript uses to override the R home, and then calls the original Rscript binary.
AFAICT there is no need to patch the binaries with install_name_tool, because DYLD_LIBRARY_PATH takes precedence even over absolute paths. Using install_name_tool and otool is not great, anyway, because they are not part of a vanilla macOS installation.
Similarly, AFAICT there is no need to patch CRAN binary packages after install.packages(), either. CRAN binaries work OOTB, without patching.
Linux
-
The difficulty here is the system packages. We need to use the local package manage (i.e. apt, dpkg, etc) to download system packages and install them into the R installation. Based on some quick tests, this is possible. We'll need to create some symlinks for BLAS/LAPACK, otherwise it is pretty straightforward, at least on Debian/Ubuntu.
-
We'll need to update the hardcoded paths in scripts.
-
We need to replace Rscript with a script, as discussed above for macOS.
Windows
On Windows, this seems easy. It is possible that we'll need to replace Rscript.exe, see below at macOS.
macOS
On macOS we can set
DYLD_LIBRARY_PATHin theRstartup script:Positron can't handle this (yet), so temporarily we'll set
R_HOME_DIRto a constant first, because this is what Positron parses from theRfile.We'll also need to update the hardcoded paths in some script files.
The most hacky part is working around the install path being hardcoded into the Rscript binary. We'll need to replace that with a shell script that sets
RHOME, which Rscript uses to override the R home, and then calls the original Rscript binary.AFAICT there is no need to patch the binaries with
install_name_tool, becauseDYLD_LIBRARY_PATHtakes precedence even over absolute paths. Usinginstall_name_toolandotoolis not great, anyway, because they are not part of a vanilla macOS installation.Similarly, AFAICT there is no need to patch CRAN binary packages after
install.packages(), either. CRAN binaries work OOTB, without patching.Linux
The difficulty here is the system packages. We need to use the local package manage (i.e. apt, dpkg, etc) to download system packages and install them into the R installation. Based on some quick tests, this is possible. We'll need to create some symlinks for BLAS/LAPACK, otherwise it is pretty straightforward, at least on Debian/Ubuntu.
We'll need to update the hardcoded paths in scripts.
We need to replace Rscript with a script, as discussed above for macOS.