From 745f1a75eac58fe768e552e9fb3179feecd7f343 Mon Sep 17 00:00:00 2001 From: chross22 <52218551+chross22@users.noreply.github.com> Date: Fri, 7 Aug 2026 16:49:33 -0400 Subject: [PATCH] Install a built tarball, so the vignette is actually installed vignette("datamatch") came back empty after every rebuild. The script ran `R CMD INSTALL` on the source directory, and installing a directory copies the .Rmd without building the vignette index, so nothing is registered. `--build-vignettes` is not the fix: it belongs to R CMD build, and R CMD INSTALL answers "unknown option" and carries on succeeding. That was worth finding out rather than assuming, since the run reported success either way. So the script now builds a tarball once and installs that into each R. Slower by the length of a build, and the only way the index reaches the library. Vignettes need pandoc, which is often only present on a Mac as the copy RStudio bundles, so that is added to PATH when nothing else provides one. Without pandoc the build retries with --no-build-vignettes rather than failing: an installed package without a vignette beats no installed package, and it says which happened. Verified: vignette("datamatch") now resolves in both R 4.6.1 and 4.3.2. Co-Authored-By: Claude Opus 5 --- inst/scripts/install_all.sh | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/inst/scripts/install_all.sh b/inst/scripts/install_all.sh index b583f83..41e4110 100755 --- a/inst/scripts/install_all.sh +++ b/inst/scripts/install_all.sh @@ -61,14 +61,49 @@ if $check_only; then exit 0 fi +# A tarball is built once and installed into each R, rather than installing the +# source directory. Installing a directory skips vignettes entirely - R CMD +# INSTALL has no option to build them, and --build-vignettes belongs to R CMD +# build - so vignette("datamatch") comes back empty however often the package is +# reinstalled. Building first is the only way the vignette index reaches the +# library. +# +# Vignettes need pandoc. RStudio bundles one, which is often the only copy on a +# Mac, so it is added to PATH when nothing else provides it. Without pandoc the +# build falls back to skipping vignettes rather than failing: an installed +# package without a vignette beats no installed package. echo +build_dir="$(mktemp -d)" +trap 'rm -rf "$build_dir"' EXIT + +rstudio_pandoc="/Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools" +if ! command -v pandoc >/dev/null 2>&1 && [[ -x "$rstudio_pandoc/pandoc" ]]; then + PATH="$rstudio_pandoc:$PATH" + export PATH +fi + +builder="${found[0]%script}" +echo "Building the package ..." +if ! out="$(cd "$build_dir" && "$builder" CMD build "$pkg_root" 2>&1)"; then + echo "$out" >&2 + echo "Build failed; retrying without vignettes." >&2 + if ! out="$(cd "$build_dir" && "$builder" CMD build --no-build-vignettes "$pkg_root" 2>&1)"; then + echo "$out" >&2 + echo "FAILED to build" >&2 + exit 1 + fi + echo "Built without vignettes. Install pandoc for vignette(\"datamatch\")." >&2 +fi + +tarball="$(ls "$build_dir"/*.tar.gz | head -1)" + for rscript in "${found[@]}"; do r="${rscript%script}" # /path/to/Rscript -> /path/to/R version="$("$rscript" --vanilla -e 'cat(paste0(R.version$major, ".", R.version$minor))' 2>/dev/null)" echo "Installing into R $version ..." # Output is kept unless the install fails, where it is the only thing that # says why. - if ! out="$("$r" CMD INSTALL "$pkg_root" 2>&1)"; then + if ! out="$("$r" CMD INSTALL "$tarball" 2>&1)"; then echo "$out" >&2 echo "FAILED for R $version" >&2 exit 1