Score:1

terminal bash loses HOME path

in flag

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/bash Failing 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
terdon avatar
cn flag
What user is running the commands? What is the output of `env | grep HOME` and `grep YOUR_USERNAME /etc/passwd` (change `YOUR_USERNAME` to your actual user name)?
terdon avatar
cn flag
Is this in the shell session ("tab") that gives the error when you run `cd`? And what user is running this? Is it the user `vackraetraed`? What is the output of `whoami` in the tab that gives the error? Please [edit] your question and include all of this information.
vackraetraed avatar
in flag
Thank you for your answer! env | grep HOME for first tab gives: HOME=/home/vackraetraed env | grep HOME for second tab gives: ... Nothing :) grep vackraetraed /etc/passwd gives in both cases: vackraetraed:x:1000:1000:My name,,,:/home/vackraetraed:/bin/bash whoami gives: vackraetraed Sorry, I could not edit the original comment after 5 mins, I am a bit now here. :)
terdon avatar
cn flag
Not the comment, the question. There is an [edit] link under the question and you can add all information there. Please do since comments are easy to miss, and can be deleted without warning. Also tell us if you tried vanadium's answer and what happened when you did.
vackraetraed avatar
in flag
I will add everything I have tried to the question!
Score:2
cn flag

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.

vackraetraed avatar
in flag
Thank you for your answer! I tried doing this but the issue still remains.
vanadium avatar
cn flag
Temporarily make a new account and see if the issue persists there. At least that allows to see whether the problem is limited to your user account instead of being a system wide config issue. Unneeded to ask whether you effectively logged out?
vackraetraed avatar
in flag
I will give it a try and get back to you. Thanks for your answer again! Yes, I restarted my laptop! :)
vackraetraed avatar
in flag
Making a new user, I did not get the message explaining how to run as root, but the error with home path when using 'cd' still existed.
vanadium avatar
cn flag
Then it must be a system configuration issue during the upgrade process. That is why in principle fresh installs are preferred. I will leave my answer up because it may help in other cases.
vackraetraed avatar
in flag
Ah, you may be right. I might just decide to make a fresh installation when I have a weekend free. The issue does not really prevent me from working, since I usually do not open the terminal this way. Thank you for taking your time to try and help me!
vanadium avatar
cn flag
See my edited answer: you may be seeing a bug in gnome-terminal 3.38.1. Check the version of your terminal in Help - About. Should have been worked around in 3.38.2, but apparently that version is not yet in Ubuntu 21.04 (unless your system is not yet up to date).
vanadium avatar
cn flag
...I confirm the version is still 3.38.1. So certainly do not reinstall: it will not help. With some luck, 3.38.2 will make it soon into 21.04. Otherwise, the forthcoming 20.10 will be around in about a month.
vackraetraed avatar
in flag
Oh I see, so it was a bug in gnome-terminal 3.38.1? (that is the version I have, just checked) Awesome, that you found it! Thank you very much for your help.
vanadium avatar
cn flag
Please "accept" the answer since it identified the issue.
vackraetraed avatar
in flag
Think I did it now! Let me know if there is anything else I should do.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.