~/.bashrc modification during installation hard codes the user's $PATH

request_recorded

#1

While installing cryoSPARC v2 I noticed how the installer adds the necessary paths to $PATH and it could potentially give users issues.

This was the bare ~/.bashrc of the user that installed cryoSPARC v2:
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

During the installation I told cryoSPARC v2 to add the path(s) to the ~/.bashrc file. So after the install I took a look at the ~/.bashrc file and found this:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
export PATH=/usr/local/cryosparc2/cryosparc2_master/deps/external/mongodb/bin:/usr/local/cryosparc2/cryosparc2_master/deps/anaconda/bin:/usr/local/cryosparc2/cryosparc2_master/bin:/usr/local/cryosparc2/cryosparc2_master/deps/anaconda/bin:/usr/local/cryosparc2/cryosparc2_master/bin:/usr/local/cuda-10.0/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/cryosparc2-user/.local/bin:/home/cryosparc2-user/bin
# Added by cryoSPARC:
export PATH="/usr/local/cryosparc2/cryosparc2_master/bin":$PATH

It looks like the cryoSPARC v2 installation (Or one of the dependencies) is spitting out the environment $PATH into an export statement in the ~/.bashrc. This is an issue since the ~/.bashrc is sourced after /etc/profile and with these modifications is essentially hard coding a user’s path.

Would you please look into where this is occurring and fix it?

P.S. Sorry I was unable to figure out how to get the text of the really long export PATH line to wrap nicely.


#2

Hi @clil16,

Thank you for pointing this out! It seems like this is happening when the mongod binaries are being installed. We’ll take a look into this and release a fix as soon as possible.


#3

If you’re looking at this anyway, it would also be a good time to switch the order of the old $PATH and the cryosparc bin directory. That way, cryosparc anaconda won’t clobber the user’s own python, etc. but the cryosparc binaries will be available and work normally.

I.e. it should be:
export PATH=$PATH:"/usr/local/cryosparc2/cryosparc2_master/bin"


#4

I agree with Daniel.

Besides, I found that I can simply run cryosparcm and cryosparcw to start cryoSPARC2 without anything from cryoSPARC2 in $PATH (strings “cryo” or “mongo” doesn’t show up at all in my $PATH). So it seems that cryoSPARC2 has already done a good job self-containing itself and there is no need for the deps to be inserted to $PATH.

This may be unnecessary, but further removing the “cryosparc2_master/bin” and “cryosparc2_worker/bin” directories from the user’s $PATH can also be easily done (so that we do not get an extra line from cryoSPARC2 in .bashrc every time it upgrades). This requires changing one line each in scripts cryosparcm and cryosparcw:

script_dir="$( cd "$(dirname "$0")" ; pwd -P )"
to
script_dir="$(dirname "$(realpath "$0")")"

Then this allows running them through symbolic links put in, e.g., /usr/local/bin.