Opening new tab in gnome-terminal launched from nautilus loses most environment variables

Bug #1922839 reported by Matthew Ruffell
36
This bug affects 5 people
Affects Status Importance Assigned to Milestone
GNOME Terminal
Fix Released
Unknown
gnome-terminal (Ubuntu)
Fix Released
Medium
Gunnar Hjalmarsson
Hirsute
Fix Released
Medium
Gunnar Hjalmarsson

Bug Description

[Impact]

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

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"?

[Testcase]

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:

https://launchpad.net/~mruffell/+archive/ubuntu/lp1922839-test

The build in the ppa has 16bd9f6a4181d37af2769e7ca5a1f9a1211cfaac reverted.

If you install this package, environment variables will be set correctly.

[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 <email address hidden>
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:

https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/253

The reverted commit is:

commit 16bd9f6a4181d37af2769e7ca5a1f9a1211cfaac
Author: Christian Persch <email address hidden>
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 fd5ac772154426e2da5afd633b336414bca33be9.

Revision history for this message
Matthew Ruffell (mruffell) wrote :

Version tested in hirsute is 3.38.1-1ubuntu1.
I checked Groovy, with 3.38.0-1ubuntu1.1, and the problem does not happen.

Both systems using Wayland session.

tags: added: hirsute
Revision history for this message
Matthew Ruffell (mruffell) wrote :

Seems this is a long running issue.

Upstream bug:
https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/253

Revision history for this message
Matthew Ruffell (mruffell) wrote :
Revision history for this message
Matthew Ruffell (mruffell) wrote :

It seems the revert for "screen: Use clean env when creating new tab" is already in 3.38.1, and I checked the Ubuntu source package, and the revert is in place.

https://gitlab.gnome.org/GNOME/gnome-terminal/-/commit/16bd9f6a4181d37af2769e7ca5a1f9a1211cfaac

Interesting.

I might try a test build which reverts the revert and see how that goes, since that matches the case on Groovy.

description: updated
Revision history for this message
Matthew Ruffell (mruffell) wrote :

Attached is a debdiff for Hirsute which re-applies "screen: Use clean env when creating new tab" and is the same patch in the PPA.

description: updated
description: updated
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "gnome-terminal debdiff for hirsute" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]

tags: added: patch
tags: added: rls-ff-incoming
tags: added: rls-hh-incoming
removed: rls-ff-incoming
Revision history for this message
Iain Lane (laney) wrote :

I'll handle this, probably after Hirsute releases. Thanks!

Changed in gnome-terminal (Ubuntu Hirsute):
assignee: nobody → Iain Lane (laney)
tags: removed: rls-hh-incoming
Mathew Hodson (mhodson)
Changed in gnome-terminal (Ubuntu Hirsute):
importance: Undecided → Medium
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gnome-terminal (Ubuntu Hirsute):
status: New → Confirmed
Changed in gnome-terminal (Ubuntu):
status: New → Confirmed
Revision history for this message
Stepan Roucka (rouckas) wrote (last edit ):

A quick workaround is to install the gnome-terminal version >= 3.38.2. E.g. 3.38.3 from debian repos here: https://packages.debian.org/bullseye/gnome-terminal

edit: and you will also need to install the nautilus-extension-gnome-terminal from debian

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Sponsored to impish and hirsute.

Changed in gnome-terminal (Ubuntu):
assignee: Iain Lane (laney) → Gunnar Hjalmarsson (gunnarhj)
status: Confirmed → Fix Committed
Changed in gnome-terminal (Ubuntu Hirsute):
assignee: Iain Lane (laney) → Gunnar Hjalmarsson (gunnarhj)
status: Confirmed → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gnome-terminal - 3.38.1-1ubuntu2

---------------
gnome-terminal (3.38.1-1ubuntu2) impish; urgency=medium

  * Fix environment variables on opening new tab via the "Open in
    Terminal" right click menu in Nautilus. (LP: #1922839)
    - d/p/screen-Use-clean-env-when-creating-new-tab.patch

 -- Matthew Ruffell <email address hidden> Tue, 13 Apr 2021 13:44:53 +1200

Changed in gnome-terminal (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Matthew, or anyone else affected,

Accepted gnome-terminal into hirsute-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/gnome-terminal/3.38.1-1ubuntu1.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-hirsute to verification-done-hirsute. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-hirsute. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in gnome-terminal (Ubuntu Hirsute):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-hirsute
Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Accomplished the steps in the testcase using version 3.38.1-1ubuntu1.1 of the gnome-terminal binaries from hirsute-proposed, and could verify that the env vars are set as expected with the proposed packages.

tags: added: verification-done verification-done-hirsute
removed: verification-needed verification-needed-hirsute
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gnome-terminal - 3.38.1-1ubuntu1.1

---------------
gnome-terminal (3.38.1-1ubuntu1.1) hirsute; urgency=medium

  * Fix environment variables on opening new tab via the "Open in
    Terminal" right click menu in Nautilus. (LP: #1922839)
    - d/p/screen-Use-clean-env-when-creating-new-tab.patch

 -- Matthew Ruffell <email address hidden> Tue, 13 Apr 2021 13:44:53 +1200

Changed in gnome-terminal (Ubuntu Hirsute):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for gnome-terminal has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Changed in gnome-terminal:
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.