Harvard-ACMG / cannon-env

Linux environment files for the FASRC Cannon cluster.
Other
0 stars 0 forks source link

Bug in .bashrc file #3

Closed laestrada closed 6 months ago

laestrada commented 6 months ago

running the copy-cannon-env script as described in the readme sets up the default .bashrc file (root/.bashrc). The final 3 lines of this script are:

[[ -f ~/.my_personal_settings ]] && . ~/.my_personal_settings
[[ -f ~/.bash_aliases         ]] && . ~/.bash_aliases
[[ -f ~/.bash_functions       ]] && . ~/.bash_functions

By default there are no ~/.bash_aliases or ~/.bash_functions files in user home directories. Using the [[ -f ~/.bash_aliases ]] && . ~/.bash_aliases shorthand causes the exit code 1 to persist after the line is run when no .bash_aliases file exists.

This causes any scripts that call ~/.bashrc (to set up a conda environment for example) to fail if they are trapping non-zero exit codes (or using set -e). This is the case in the IMI, and it can be a very confusing error for new group members getting set up for the first time.

I propose one of the following:

  1. Creating blank .bash_aliases and .bash_functions files that are copied into user run directories by default.
  2. Replacing the [[ -f ~/.bash_functions ]] && . ~/.bash_functions syntax with standard if statements. If statements do not have this same exit code persistence that cause error traps to fail as described here.
yantosca commented 6 months ago

Thanks @laestrada! I've fixed this and have pushed a patch release 2.0.5. We can close out this issue now.