terminal bash loses HOME path

I upgraded Ubuntu to 21.04.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.04
Release: 21.04
Codename: hirsute

Now when I open a terminal from the file explorer and open a new tab using Ctrl+shift+t I get the following message in the terminal:

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

After this, if I try to use "cd" I get the following error:

$ cd
bash: cd: HOME not set

Has anyone had similar problems or know why this is happening? I have never had issues like this before.

Solution:Bug in gnome-terminal 3.38.1, should be fixed in 3.38.2 See vanadium's answer.

Suggestions tried:

  1. $ env | grep HOME

    Working tab:HOME=/home/vackraetraed

    Failing tab:

  2. $ grep vackraetraed /etc/passwd

    Working tab: vackraetraed:x:1000:1000:My name,,,:/home/vackraetraed:/bin/bashFailing tab: vackraetraed:x:1000:1000:My name,,,:/home/vackraetraed:/bin/bash

  3. $ whoami

    Working tab: vackraetraed

    Failing tab: vackraetraed

  4. Copy system default files to user: $ cp -r /etc/skel/.bashrc ~ ; cp -r /etc/skel/.profile ~

    • Issue persists
  5. Try the issue with a new temp user login

    • No instructions on how to run as root when tab opens
    • 'cd' still does not work
5

1 Answer

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.

11

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like