terminal bash loses HOME path

Solution 1:

You may be facing a bug: Env vars differ in first and second terminal of which this (in second tab, err happend when run cd: bash: cd: HOME not set) is a duplicate. It is a design issue with the systemd --user / d-bus activation environment. In Gnome Terminal 3.38.2, that issue should be "fixed" with a patch that copies over the environment of the first tab. Unfortunately, as of today (2021-09-08), gnome-terminal is still at 3.38.1.

For other users observing strange issues with terminal output, it may be due to a misconfiguration with the .profile or .bashrc configuration files. Take a look at them and correct them. Else you may want to revert to the system default files over to your user configuration. Copy the original files to a backup copy in case you want to revert to them:

cp ~/.bashrc ~/.bashrc_bak ; cp ~/.profile ~/.profile_bak

and then copy the system default files to your profile:

cp -r /etc/skel/.bashrc ~ ; cp -r /etc/skel/.profile ~

Log out then back in before testing if the issue is resolved.