Re: bashrc question
On 2024-12-26, henrik@privatembox.com <henrik@privatembox.com> wrote:
> Hello
>
> I have these settings in .bashrc of my home dir:
>
> $ cat .bashrc
> export TF_CPP_MIN_LOG_LEVEL=3
> export CUDA_VISIBLE_DEVICES=-1
>
> but every time after i login the system, the settings are not activated.
> I have to source it by hand to make it work.
>
> what's wrong with me?
>
> Thanks.
>
>
If your .bashrc settings are not applied automatically after login, here are
possible reasons and solutions:
.bashrc Might Not Be Sourced on Login Cause: .bashrc is typically sourced
for non-login shells, while .bash_profile or .profile is sourced for login
shells.
Solution: Add the following line to your .bash_profile (or .profile):
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
This ensures that .bashrc is sourced whenever you log in.
Login Shell Behavior Cause: If you're logging in through a graphical
environment (e.g., GNOME, KDE), it might not start a login shell.
Solution: Configure your terminal emulator to launch as a login shell. For
example:
In GNOME Terminal: Go to Preferences > Profiles > Command and check "Run
command as a login shell".
Shell Type
Cause: If your default shell is not bash, your .bashrc will not be read.
Solution: Confirm your default shell with:
echo $SHELL
If the result is not /bin/bash, change your shell to bash:
chsh -s /bin/bash
Cause: Errors in .bashrc might prevent it from being sourced.
Solution: Check .bashrc for syntax errors:
bash -n ~/.bashrc
Fix any errors if found.
Reply to: