Fix R bundling: SIGPIPE abort and wrong R_HOME path

Two bugs found by the first real build:

- 'R --version | head -1' aborted the script with exit 141 under
  'set -o pipefail': head closes the pipe and R dies of SIGPIPE. Use
  'sed -n 1p', which consumes all input.
- R installed to lib64/R, not the lib/R the script assumed. Pin --libdir
  and ask 'R RHOME' for the real path instead of guessing.

Also stop exporting R_HOME. R.cmake warns that a set R_HOME makes R emit
'WARNING: ignoring environment value of R_HOME', which corrupts the output
cmake parses; CUSTOM_R_PATH is the supported way to select an R.
This commit is contained in:
agw
2026-09-01 21:55:00 +02:00
parent d880e6748c
commit 7b39a5b06e
+13 -4
View File
@@ -99,9 +99,13 @@ tar -xzf "R-${R_VERSION}.tar.gz"
cd "R-${R_VERSION}"
# --enable-R-shlib is required: JASP embeds R through RInside/libR.
# rpath is set to $ORIGIN-relative so the tree stays relocatable after install.
# --libdir is pinned so R lands in lib/R rather than the lib64/R that Arch's
# config.site would otherwise pick, which keeps the rpath below predictable.
# The install prefix equals the final install path, so the rpath stays valid
# once the tarball is unpacked on the user's machine.
./configure \
--prefix="${R_HOME_DIR}" \
--libdir="${R_HOME_DIR}/lib" \
--enable-R-shlib \
--enable-memory-profiling \
--with-blas \
@@ -112,9 +116,14 @@ cd "R-${R_VERSION}"
make -j"$JOBS"
make install
export R_HOME="${R_HOME_DIR}/lib/R"
export PATH="${R_HOME_DIR}/bin:${PATH}"
R --version | head -1
# Ask R where it actually put itself rather than assuming lib vs lib64.
# Deliberately NOT exported: R.cmake notes that a set R_HOME makes R print
# "WARNING: ignoring environment value of R_HOME", which corrupts the output it
# parses. CUSTOM_R_PATH is the supported way to point JASP at a specific R.
JASP_R_HOME="$("${R_HOME_DIR}/bin/R" RHOME)"
log "bundled R_HOME is ${JASP_R_HOME}"
"${R_HOME_DIR}/bin/R" --version | sed -n 1p || true
# ------------------------------------------------------------------- checkout
log "cloning jasp-desktop $JASP_TAG"
@@ -140,7 +149,7 @@ cmake -S "$SRC_DIR" -B "$BUILD_DIR" -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DLINUX_LOCAL_BUILD=OFF \
-DCUSTOM_R_PATH="${R_HOME}" \
-DCUSTOM_R_PATH="${JASP_R_HOME}" \
-Wno-dev
log "compiling JASP (-j$JOBS)"