Skip to content

Instantly share code, notes, and snippets.

@PRO-2684
Last active June 25, 2026 06:57
Show Gist options
  • Select an option

  • Save PRO-2684/dcede86c9795ac22764bda3f1e4c1014 to your computer and use it in GitHub Desktop.

Select an option

Save PRO-2684/dcede86c9795ac22764bda3f1e4c1014 to your computer and use it in GitHub Desktop.
Lazy conda

Setup conda env lazily when LC_LAZY_CONDA present. Add the following line to your ssh config:

 Host server
   HostName ssh.my-server.com
   User ubuntu
+  SetEnv LC_LAZY_CONDA=1
if [[ -n "${LC_LAZY_CONDA:-}" ]]; then
# Set up conda lazily when LC_LAZY_CONDA present
# Need LC_ prefix, since most server `AcceptEnv LANG LC_*`
CONDA_ROOT="/data/apps/miniforge3" # Adjust according to your setup
conda() {
unset -f conda
if [[ -f "$CONDA_ROOT/etc/profile.d/conda.sh" ]]; then
. "$CONDA_ROOT/etc/profile.d/conda.sh"
else
export PATH="$CONDA_ROOT/bin:$PATH"
fi
conda "$@"
}
else
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/data/apps/miniforge3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/data/apps/miniforge3/etc/profile.d/conda.sh" ]; then
. "/data/apps/miniforge3/etc/profile.d/conda.sh"
else
export PATH="/data/apps/miniforge3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment