diff --git a/Scripts/r.sh b/Scripts/r.sh index 3f38d7f..2739209 100644 --- a/Scripts/r.sh +++ b/Scripts/r.sh @@ -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." diff --git a/Scripts/setup.sh b/Scripts/setup.sh index 28afafa..e1e01f4 100644 --- a/Scripts/setup.sh +++ b/Scripts/setup.sh @@ -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() {