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"
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
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.
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
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.
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.
Created attachment 12415 [details, diff] portage patch same for portage
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')?
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.
this bugs is also exercised when emacs users attempt to emerge somthing in eshell and shell modes.
Fixed for next release... os.environ.has_key("TERM")