Improve renv logging and stow output

This commit is contained in:
MangoPig
2026-06-03 22:40:18 +01:00
parent 88817aa7d2
commit 2429eb3603
2 changed files with 47 additions and 2 deletions

View File

@@ -138,8 +138,45 @@ fi
export R_LIBS_USER="$R_LIB_DIR"
echo -e "${BLUE} LOG:${YELLOW} Installing 'renv' package in the user R library...${NC}"
if compgen -G "$R_LIB_DIR/00LOCK*" >/dev/null 2>&1; then
echo -e "${RED} ERROR:${NC} Detected existing R package lock(s) in $R_LIB_DIR"
find "$R_LIB_DIR" -maxdepth 1 -type d -name '00LOCK*' -print | sed 's/^/ - /'
echo -e "${YELLOW} LOG:${NC} This usually means a previous R package install was interrupted."
echo -e "${YELLOW} LOG:${NC} Remove the stale lock directory/directories above, then rerun the command."
exit 1
fi
"$R_BIN_DIR/Rscript" --vanilla -e 'user_lib <- path.expand(Sys.getenv("R_LIBS_USER", unset = "~/.programming/r/library")); dir.create(user_lib, recursive = TRUE, showWarnings = FALSE); .libPaths(c(user_lib, .libPaths())); if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv", lib = user_lib, repos = "https://cloud.r-project.org", quiet = TRUE)'
echo -e "${BLUE} LOG:${YELLOW} Installing 'renv' package in the user R library...${NC}"
echo -e "${BLUE} LOG:${YELLOW} R user library: $R_LIB_DIR${NC}"
echo -e "${BLUE} LOG:${YELLOW} R executable: $R_BIN_DIR/Rscript${NC}"
"$R_BIN_DIR/Rscript" --vanilla - <<'EOF'
user_lib <- path.expand(Sys.getenv("R_LIBS_USER", unset = "~/.programming/r/library"))
dir.create(user_lib, recursive = TRUE, showWarnings = FALSE)
.libPaths(c(user_lib, .libPaths()))
cat("R user library:", user_lib, "\n")
cat("R library paths:", paste(.libPaths(), collapse = " | "), "\n")
if (requireNamespace("renv", quietly = TRUE)) {
cat("renv is already installed.\n")
quit(save = "no", status = 0)
}
cat("Installing renv from CRAN...\n")
install.packages(
"renv",
lib = user_lib,
repos = "https://cloud.r-project.org",
quiet = FALSE
)
cat("Verifying renv installation...\n")
if (!requireNamespace("renv", quietly = TRUE)) {
stop("renv install finished but the package is still unavailable.")
}
cat("renv installation verified.\n")
EOF
echo -e "${GREEN} SUCCESS:${NC} R setup completed."

View File

@@ -102,11 +102,19 @@ backup_conflicting_home_files() {
}
stow_dotfiles() {
echo "Preparing repo-managed secrets for stow..."
sync_repo_managed_secret_file
echo "Checking for conflicting home dotfiles before stow..."
backup_conflicting_home_files
echo "Cleaning existing Zsh stow links..."
stow --dir="$REPO_ROOT" -D Zsh --target="$HOME" 2>/dev/null || true
echo "Stowing Zsh dotfiles..."
stow --dir="$REPO_ROOT" Zsh --target="$HOME"
echo "Zsh dotfiles stowed."
}
bootstrap_only() {