[Bug 1922839] [NEW] Opening new tab in gnome-terminal launched from nautilus loses most environment variables

Launchpad Bug Tracker 1922839 at bugs.launchpad.net
Tue Apr 13 04:24:45 UTC 2021

You have been subscribed to a public bug by Ubuntu Foundations Team Bug Bot (crichton):


If you launch gnome-terminal by right clicking a directory in Nautilus,
selecting "Open in Terminal", you get a fully functional terminal

If you then press the new tab button, or ctrl-shift-t to open a new
terminal tab, you will find that most environment variables have become
unset, and you see the text:

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

Comparing printenv between:

Normal terminal: https://paste.ubuntu.com/p/2hcCY9hbHQ/
Broken new terminal tab: https://paste.ubuntu.com/p/zYsjRHVJH7/

Most commands won't run in the new terminal tab, due to $HOME and $USER
not being set.

Note, if you launch gnome-terminal from gnome-shell or the dock, and
create a new tab, everything works perfectly. Is something wrong with
the Nautilus option for "Open in Terminal"?


1. Launch Nautilus to home directory
2. Right click > "Open in Terminal"
3. Run "printenv" to see full list of env variables
4. Click new tab button, or ctrl-shift-t
5. Run "printenv" see the lack of env variables

I have a test package available in the below ppa:


The build in the ppa has 16bd9f6a4181d37af2769e7ca5a1f9a1211cfaac

If you install this package, environment variables will be set

[Where problems could occur]

I think there is some risk with re-instating a commit which has been
reverted, and users could run into similar issues as found in the
upstream bug.

We do have some supporting evidence that the commit isn't too harmful,
since it is applied to Groovy currently, things work as intended there,
and users haven't complained about the issues in the upstream bug
applying to Groovy.

If a regression were to occur, then launching a new gnome-terminal or
opening a new tab could land the user with a terminal with little to no
environment variables set. A workaround will be to launch gnome-terminal
from gnome-shell overview.

[Other info]

Focal and Groovy have the following commit applied:

commit fd5ac772154426e2da5afd633b336414bca33be9
Author: Christian Persch <chpe at src.gnome.org>
Date:   Mon Mar 23 09:57:56 2020 +0100
Subject: screen: Use clean env when creating new tab
Link: https://gitlab.gnome.org/GNOME/gnome-terminal/-/commit/fd5ac772154426e2da5afd633b336414bca33be9

This was then reverted in 3.38.1 due to the upstream bug:


The reverted commit is:

commit 16bd9f6a4181d37af2769e7ca5a1f9a1211cfaac
Author: Christian Persch <chpe at src.gnome.org>
Date:   Thu Sep 17 17:10:47 2020 +0200
Subject: Revert "screen: Use clean env when creating new tab"
Link: https://gitlab.gnome.org/GNOME/gnome-terminal/-/commit/16bd9f6a4181d37af2769e7ca5a1f9a1211cfaac

This revert seems to have broken Hirsute. If we revert the revert, that
is, apply the commit again, things work as intended.

To fix this, we need to re-apply

** Affects: gnome-terminal (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: gnome-terminal (Ubuntu Hirsute)
     Importance: Undecided
         Status: New

** Tags: hirsute patch
Opening new tab in gnome-terminal launched from nautilus loses most environment variables
You received this bug notification because you are a member of Ubuntu Sponsors Team, which is subscribed to the bug report.

More information about the Ubuntu-sponsors mailing list