Bashrc file prevents me from login the machine locally

Hi:

I’m using Rocky Linux 9.3 (Blue Onyx), and I found this weird issue: if I use this long bashrc file, then I can’t login the machine locally with this ‘Oh no there is a problem’, but I can still login remotely through ssh, so it’s probally a genome display issue. But when I use the second bashrc(the short one), then I can login both localy and remotely.

1.long bashrc

# .bashrc

export LD_LIBRARY_PATH=/home/mumeijin/opt/GaussView6/gv6/gv/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/mumeijin/opt/GaussView6/gv6/gv/lib/MesaGL:$LD_LIBRARY_PATH

alias sl='ls --color=auto'
alias ll='ls -ltr'
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -lth'
alias la='ls -A'
alias l='ls -CF'

export psi4=/home/mumeijin/opt/psi4/
export PATH=$psi4/bin:$PATH

source /opt/intel/cce/10.1.011/bin/iccvars.sh
source /opt/intel/fce/10.1.011/bin/ifortvars.sh

export g16root="/opt/software/Gaussian16/bin/avx"
source $g16root/g16/bsd/g16.profile
export GAUSS_SCRDIR="/scratch"
export PATH=$PATH:g16root/g16

alias vmd="/home/mumeijin/opt/vmd-1.9.4/vmd"
alias gview="/home/mumeijin/Software/GaussView\ 6.0.16\ Linux\ x64/gv/gview.sh"

# ORCA 6.0.0 secion
export PATH=/home/mumeijin/opt/orca_6_0_0:$PATH
#openmpi
export openmpi=/usr/lib64/openmpi/
export PATH=$openmpi/bin:$PATH
export LD_LIBRARY_PATH=$openmpi/lib:$LD_LIBRARY_PATH

#original

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

# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH

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

# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
	for rc in ~/.bashrc.d/*; do
		if [ -f "$rc" ]; then
			. "$rc"
		fi
	done
fi

unset rc



# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/mumeijin/opt/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/mumeijin/opt/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/home/mumeijin/opt/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/mumeijin/opt/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
  1. short one:
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH

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

# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
	for rc in ~/.bashrc.d/*; do
		if [ -f "$rc" ]; then
			. "$rc"
		fi
	done
fi

unset rc

The issue I got that I can’t login:

I really have no idea what’s wrong since the most part of the long bashrc are just software path and color management, please let me know if you need more information, really appreciate!

This can be solved with basic troubleshooting.

If I were you I would comment out every line (or function) at a time in your bashrc that’s not in the version that works, then re-enable one line at a time and find out which line or function causes it to fail.

1 Like

Indeed.


Note the

# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
	for rc in ~/.bashrc.d/*; do
		if [ -f "$rc" ]; then
			. "$rc"
		fi
	done
fi

unset rc

at the end of the default .bashrc. You can create directory .bashrc.d and add you custom config there as (multiple) file(s). That is perhaps even easier than comment/uncomment and more clear as all your customizations will be in “obvious” place, rather than sprinkled within the main .bashrc.


We have used package environment-modules (and now its variant, Lmod from EPEL). The idea of these modules is to have per-application config in separate files that user explicitly loads on need, rather than on login. (Properly written modules can also unload, restoring previous environment.)

The gcc-devtoolsets pull in scl, which now requires modules (as does openmpi). Users of those thus have the package already installed.