From 7cc02641779f3105ec4c0b83f7dfbda8b729fb18 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Fri, 2 Aug 2024 20:09:11 -0400 Subject: [PATCH] Fix R lib install --- workflow/qhtcp-workflow | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/workflow/qhtcp-workflow b/workflow/qhtcp-workflow index 3ef8b8e9..a246f739 100755 --- a/workflow/qhtcp-workflow +++ b/workflow/qhtcp-workflow @@ -275,7 +275,7 @@ backup() { } # @description Prints a helpful message add program start -print_header() { +interactive_header() { debug "Running: ${FUNCNAME[0]}" cat <<-'EOF' @@ -1643,18 +1643,6 @@ main() { declare -g RSCRIPT="${RSCRIPT:-$(which Rscript 2>/dev/null)}" declare -g MATLAB="${MATLAB:-$(which matlab 2>/dev/null)}" - # Use a custom R library - if [[ -z $R_LIBS_USER || $R_LIBS_USER != "$HOME/R/$SCRIPT_NAME" ]]; then - echo "This script uses a custom R library at $HOME/R/$SCRIPT_NAME" - echo "You can install the R dependencies to this library using the install_dependencies module" - if ((YES)) || ask "Would you like to make this library the default for your user?"; then - echo "Adding R_LIBS_USER=$HOME/R/$SCRIPT_NAME to your .bashrc" - echo "export R_LIBS_USER=$HOME/R/$SCRIPT_NAME" >> "$HOME/.bashrc" - fi - else - debug "R_LIBS_USER already set to $HOME/R/$SCRIPT_NAME" - fi - # Global vars SCRIPT_NAME="${BASH_SOURCE[0]}" SCRIPT=$(realpath -s "${BASH_SOURCE[0]}") @@ -1714,6 +1702,19 @@ main() { fi fi + # Ask to make our custom R library the default + if [[ -z $R_LIBS_USER || $R_LIBS_USER != "$HOME/R/$SCRIPT_NAME" ]]; then + echo "This script uses a custom R library at $HOME/R/$SCRIPT_NAME" + echo "You can install the R dependencies to this library using the install_dependencies module" + if ((YES)) || ask "Would you like to make this library the default for your user?"; then + echo "Adding R_LIBS_USER=$HOME/R/$SCRIPT_NAME to your .bashrc" + echo "export R_LIBS_USER=$HOME/R/$SCRIPT_NAME" >> "$HOME/.bashrc" + fi + else + debug "R_LIBS_USER already set to $HOME/R/$SCRIPT_NAME" + fi + + # Make sure we are using the absolute path OUT_DIR=$(realpath -s "$OUT_DIR") @@ -1725,7 +1726,7 @@ main() { parse_input "$@" # parse arguments with getopt - print_header "$@" + interactive_header "$@" # # Prompt user for the PROJECT if we still don't have one # if [[ ${#PROJECTS[@]} -eq 0 ]]; then