Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring shell defaults and development setup on HAL DGX #14

Open
matthewfeickert opened this issue Apr 28, 2022 · 1 comment
Open

Comments

@matthewfeickert
Copy link
Member

After the NCSA team setup a login node for the HAL DGX box (c.f. Access hal-dgx and overdrive with hal-login3 Node) the .bash_profile based setup workflow failed as

When invoked as an interactive login shell, Bash looks for the /etc/profile file, and if the file exists, it runs the commands listed in the file. Then Bash searches for ~/.bash_profile, ~/.bash_login, and ~/.profile files, in the listed order, and executes commands from the first readable file found.

When Bash is invoked as an interactive non-login shell, it reads and executes commands from ~/.bashrc, if that file exists, and it is readable.

So as the NCSA team

... have prepared a hal-login3 machine as a login node so that users can request computational resources from hal-dgx and overdrive.

then when an interactive session on HAL DGX is requested it will not be a login shell and so ~/.bash_profile will never be sourced.

The solution then is to move all the components that were in ~.bash_profile into ~/.basrc_user. So this will require rewrites of migrate_home.sh and pyenv_setup.sh.

@matthewfeickert
Copy link
Member Author

So this is what a .bashrc_user that works would look like

#!/usr/bin/env bash

export __HOME="/home/${USER}"
export HOME="/raid/projects/${USER}"

# Enable .pythonrc.py
if [ -f "${HOME}/.pythonrc.py" ]; then
    export PYTHONSTARTUP="${HOME}/.pythonrc.py"
fi

# Ensure local virtualenv setup
if [ ! -f "${HOME}/opt/venv/bin/virtualenv" ]; then
    curl -sL --location --output /tmp/virtualenv.pyz https://bootstrap.pypa.io/virtualenv.pyz
    python3 /tmp/virtualenv.pyz ~/opt/venv
    ~/opt/venv/bin/pip install --upgrade pip
    ~/opt/venv/bin/pip install virtualenv
    mkdir -p ~/bin  # Ensure exists if new machine
    ln -s ~/opt/venv/bin/virtualenv ~/bin/virtualenv
fi

# pyenv setup
export PYENV_ROOT="${HOME}/.pyenv"
export PATH="${PYENV_ROOT}/bin:${PATH}"

eval "$(pyenv init -)"

# Place pyenv shims on path
if [[ ":${PATH}:" != *":$(pyenv root)/shims:"* ]]; then
  eval "$(pyenv init --path)"
fi
# Place pyenv-virtualenv shims on path
if [[ ":${PATH}:" != *":$(pyenv root)/plugins/pyenv-virtualenv/shims:"* ]]; then
  eval "$(pyenv virtualenv-init -)"
fi

# default venv
if [ -d "${HOME}/.pyenv/versions/base" ]; then
    pyenv activate base
fi

# Add GPG key
export GPG_TTY=$(tty)

# User specific environment and startup programs
cd "${HOME}"

PATH="${PATH}:${HOME}/.local/bin:${HOME}/bin"
export PATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant