Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 21416 - emerge errors if TERM is not defined
Summary: emerge errors if TERM is not defined
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: High normal
Assignee: Nicholas Jones (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-21 08:19 UTC by Gwenn
Modified: 2011-10-30 22:20 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge patch (emerge_patch,456 bytes, patch)
2003-05-26 07:33 UTC, Ludovic Bellier
Details | Diff
portage patch (portage_patch,409 bytes, patch)
2003-05-26 07:36 UTC, Ludovic Bellier
Details | Diff
fixes xtermTitle problems in emerge and output.py (portage-TERM.diff,844 bytes, patch)
2003-05-26 09:15 UTC, Oliver Graf
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gwenn 2003-05-21 08:19:30 UTC
The new emerge tries to change the title bar of terms
but fails if the TERM environment variable is not set.

A consequence is that emerge commands in crontab output
this trace on stderr:

Traceback (most recent call last):
  File "/usr/bin/emerge", line 279, in ?
    emergelog("Started emerge on: "+time.strftime("%b %d, %Y %H:%M:%S",
time.localtime()))
  File "/usr/bin/emerge", line 186, in emergelog
    xtermTitle(mystr)
  File "/usr/lib/python2.2/site-packages/output.py", line 34, in xtermTitle
    myt=os.environ["TERM"]
  File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
    def __getitem__(self, key): return self.data[key]
KeyError: TERM
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.2/atexit.py", line 20, in _run_exitfuncs
    apply(func, targs, kargs)
  File "/usr/bin/emerge", line 201, in emergeexit
    emergelog(" *** terminating.")
  File "/usr/bin/emerge", line 186, in emergelog
    xtermTitle(mystr)
  File "/usr/lib/python2.2/site-packages/output.py", line 34, in xtermTitle
    myt=os.environ["TERM"]
  File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
    def __getitem__(self, key): return self.data[key]
KeyError: TERM


Reproducible: Always
Steps to Reproduce:




# TERM=vt100 emerge info
Portage 2.0.48 (default-x86-1.4, gcc-3.2.2, glibc-2.3.1-r4)
=================================================================
System uname: 2.4.20-grsec i686 AMD Athlon(tm) XP 1800+
GENTOO_MIRRORS=" ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/
http://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/
http://212.219.56.152/sites/www.ibiblio.org/gentoo/
http://212.219.56.162/sites/www.ibiblio.org/gentoo/
http://212.219.56.146/sites/www.ibiblio.org/gentoo/"
CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config
/usr/kde/2/share/config /usr/kde/3/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR_OVERLAY="/usr/local/portage"
USE="x86 3dnow alsa apm berkdb cdr cjk crypt cups gd gdbm gif imap innodb jpeg
ldap libwww maildir mbox mcal mmx mysql ncurses nls oggvorbis oss pam pdflib png
readline samba slang snmp sse ssl tcp tiff truetype xml xml2 zlib"
COMPILER="gcc3"
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O3 -pipe"
CXXFLAGS="-march=athlon-xp -O3 -pipe"
ACCEPT_KEYWORDS="x86"
MAKEOPTS="-j3"
AUTOCLEAN="yes"
SYNC="rsync://granit/gentoo-portage/"
FEATURES="ccache sandbox distcc userpriv usersandbox"
Comment 1 Ludovic Bellier 2003-05-21 09:31:30 UTC
same emerge version as top

for example in crontab, "TERM" isn't defined.

Producing the bug:
  echo $TERM ; unset TERM; emerge -u world -pv; TERM="xterm"

Partial solution :
  FEATURE='notitles'
  but emerge:202 xtermTitle(os.environ["TERM"]) don't test
   <if "notitles" not in portage.features>

So I purpose :
   adding <if "notitles" not in portage.features> before each
os.environ["TERM"] access and in portage module, add "notitles" in
features if TERM not defined
Comment 2 Jonathan Rogers 2003-05-22 20:10:55 UTC
It would be best if emerge continued to work as it always has when it is not connected to a terminal, as it seems quite a number of people have automated periodic checks for updates.
Comment 3 Peter Ruskin 2003-05-24 14:51:12 UTC
This bug also prevents kportage from emerging anything:
These are the packages that I would merge, in order:
Calculating dependencies    ...done!
[ebuild  N   ] net-dns/bind-tools-9.2.2  
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.2/atexit.py", line 20, in _run_exitfuncs
    apply(func, targs, kargs)
  File "/usr/bin/emerge", line 201, in emergeexit
    emergelog(" *** terminating.")
  File "/usr/bin/emerge", line 186, in emergelog
    xtermTitle(mystr)
  File "/usr/lib/python2.2/site-packages/output.py", line 34, in xtermTitle
    myt=os.environ["TERM"]
  File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
    def __getitem__(self, key): return self.data[key]
KeyError: TERM
Traceback (most recent call last):
  File "/usr/bin/emerge", line 279, in ?
    emergelog("Started emerge on: "+time.strftime("%b %d, %Y %H:%M:%S", time.localtime()))
  File "/usr/bin/emerge", line 186, in emergelog
    xtermTitle(mystr)
  File "/usr/lib/python2.2/site-packages/output.py", line 34, in xtermTitle
    myt=os.environ["TERM"]
  File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
    def __getitem__(self, key): return self.data[key]
KeyError: TERM
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.2/atexit.py", line 20, in _run_exitfuncs
    apply(func, targs, kargs)
  File "/usr/bin/emerge", line 201, in emergeexit
    emergelog(" *** terminating.")
  File "/usr/bin/emerge", line 186, in emergelog
    xtermTitle(mystr)
  File "/usr/lib/python2.2/site-packages/output.py", line 34, in xtermTitle
    myt=os.environ["TERM"]
  File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
    def __getitem__(self, key): return self.data[key]
KeyError: TERM
Comment 4 gatto 2003-05-24 17:32:59 UTC
I set TERM=dumb in my crontab, and "notitles" in FEATURES (/etc/make.conf) to work around this for now, but I don't think either of these things should be necessary. I only have crontab set to emerge sync once a week. It gets monotonous doing it by hand every N days. I guess this bug is related to bug http://bugs.gentoo.org/show_bug.cgi?id=18780 which got marked INVALID.
Comment 5 Ludovic Bellier 2003-05-26 07:33:55 UTC
Created attachment 12414 [details, diff]
emerge patch

I post a previous comment (see top), this patch apply my comment. I don't
Gentoo development rules.
Comment 6 Ludovic Bellier 2003-05-26 07:36:11 UTC
Created attachment 12415 [details, diff]
portage patch

same for portage
Comment 7 Oliver Graf 2003-05-26 09:04:01 UTC
Wouldn't it be better to use the get method of the environ dict to get around this? I don't want to set notitles, cause if I'm in a term, I might want them. I won't set TERM in crontab either.

So why don't just use os.environ.get('TERM','dump')?
Comment 8 Oliver Graf 2003-05-26 09:15:45 UTC
Created attachment 12418 [details, diff]
fixes xtermTitle problems in emerge and output.py

the better(?) solution to solve this problem, cause it does not require user
interaction to get it right.
Comment 9 Matthew Kennedy (RETIRED) gentoo-dev 2003-05-26 12:12:15 UTC
this bugs is also exercised when emacs users attempt to emerge somthing in eshell and shell modes.
Comment 10 Nicholas Jones (RETIRED) gentoo-dev 2003-05-27 01:18:49 UTC
Fixed for next release...

os.environ.has_key("TERM")