Improve renv logging and stow output
This commit is contained in:
41
Scripts/r.sh
41
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."
|
||||
|
||||
Reference in New Issue
Block a user