Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 272201 - app-emacs/emacs-daemon-0.14: emacsclient -c fails to open display
Summary: app-emacs/emacs-daemon-0.14: emacsclient -c fails to open display
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Emacs project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-02 02:45 UTC by AJ Armstrong
Modified: 2009-06-04 05:24 UTC (History)
0 users

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


Attachments
.emacs (.emacs,15.04 KB, text/plain)
2009-06-02 13:23 UTC, AJ Armstrong
Details

Note You need to log in before you can comment on or make changes to this bug.
Description AJ Armstrong 2009-06-02 02:45:06 UTC
Per the summary.  When attempting emacsclient -c from a terminal window or "run program" dialog in X, the following error is generated:

Waiting for Emacs...
*ERROR*: Display :0.0 can't be opened

emacsclient -t works as expected

X environment: xorg-server-1.5.3-r6, xfce4-4.6.1



Reproducible: Always




aja@oberon% emerge --info                                                                                               ~/athabasca/COMP667/assignments/TME4
Portage 2.1.6.13 (default/linux/amd64/2008.0/desktop, gcc-4.3.3, glibc-2.10.1-r0, 2.6.25-gentoo-r5 x86_64)
=================================================================
System uname: Linux-2.6.25-gentoo-r5-x86_64-AMD_Athlon-tm-_64_X2_Dual_Core_Processor_4600+-with-gentoo-2.0.1
Timestamp of tree: Tue, 02 Jun 2009 01:30:01 +0000
app-shells/bash:     4.0_p24
dev-java/java-config: 2.1.8
dev-lang/python:     2.5.4-r2, 2.6.2-r1
dev-python/pycrypto: 2.0.1-r8
dev-util/cmake:      2.6.4
sys-apps/baselayout: 2.0.1
sys-apps/openrc:     0.4.3-r2
sys-apps/sandbox:    1.9
sys-devel/autoconf:  2.13, 2.63-r1
sys-devel/automake:  1.4_p6, 1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2
sys-devel/binutils:  2.19.1-r1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.29
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -O2 -pipe -msse3"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config /var/bind /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-march=athlon64 -O2 -pipe -msse3"
DISTDIR="/usr/portage/distfiles"
FEATURES="ccache distlocks fixpackages multilib-strict parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://mirror.datapipe.net/gentoo http://gentoo.chem.wisc.edu/gentoo/ ftp://mirror.datapipe.net/gentoo ftp://gentoo.chem.wisc.edu/gentoo/ http://gentoo.mirrors.tds.net/gentoo"
LANG="C"
LDFLAGS="-Wl,-O1"
LINGUAS="en en_GB"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/etc/portage/gentoo-lisp-overlay /etc/portage/overlay"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X a52 accessibility acl acpi aiglx alsa amd64 apache2 araneida arts aserve avahi bash-completion berkdb beryl bluetooth branding bzip2 cairo cdr cli cracklib crypt ctype cups dbus directfb dri dts dv dvd dvdr dvdread eds emacs emboss encode esd evo expat fam fame fbcon ffmpeg firefox fortran gcj gd gdbm gif glitz gnome gnutls gpm gstreamer gtk hal iconv ieee1394 imlib ipv6 isdnlog java java5 java6 jikes jpeg kde kerberos kpathsea latex ldap ldb libnotify lirc live mad mdnsresponder-compat midi mikmod mjpeg mmx mod_lisp mono mp3 mpeg mudflap multilib mysql ncurses nls nptl nptlonly nsplugin nvidia ogg opengl openmp pam pcre pdf perl pic plugins png ppds pppd preview-latex python qt3 qt3support qt4 quicktime readline reflection rtc sdl session spell spl sse sse2 ssl standalone startup-notification svg sysfs tcpd tetex theora threads thunar-vfs tiff truetype ucwpatch unicode usb v4l v4l2 vcd vorbis weakhashtables xcb xcomposite xinerama xml xorg xpm xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_GB" LIRC_DEVICES="livedrive_midi" NETBEANS_MODULES="apisupport harness ide java nb j2ee mobility php profiler soa visualweb webcommon websvccommon xml groovy gsf enterprise" USERLAND="GNU" VIDEO_CARDS="nvidia nv v4l vesa vga fbdev"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 AJ Armstrong 2009-06-02 02:53:29 UTC
Additional info.  The emacs daemon from init.d does not appear to be loading my ~/.emacs, either.  emacs --daemon from a terminal errors on ~/.emacs unable to find a font that is specifified, but vanilla emacs has no problem.
Comment 2 Ulrich Müller gentoo-dev 2009-06-02 05:51:10 UTC
(Please don't CC maintainers yourself, but wait for the bug wranglers to assign the bug.)

(In reply to comment #1)
> Additional info.  The emacs daemon from init.d does not appear to be loading
> my ~/.emacs, either.

Could you try the following:
- Start the Emacs daemon via the rc script
- Run "emacsclient -t" from your account
- What are the values of the following variables ("C-h v <variable> RET"):
  user-init-file, user-login-name, user-real-login-name

>  emacs --daemon from a terminal errors on ~/.emacs unable to
> find a font that is specifified,

Seems to me that you should fix this problem first. Do things work if you rename your .emacs?
Comment 3 AJ Armstrong 2009-06-02 06:59:30 UTC
(In reply to comment #2)

**Inline** 


> (Please don't CC maintainers yourself, but wait for the bug wranglers to assign
> the bug.)

OK

> (In reply to comment #1)
> > Additional info.  The emacs daemon from init.d does not appear to be loading
> > my ~/.emacs, either.
> 
> Could you try the following:
> - Start the Emacs daemon via the rc script
> - Run "emacsclient -t" from your account
> - What are the values of the following variables ("C-h v <variable> RET"):
>   user-init-file, user-login-name, user-real-login-name

Respectively:

/home/aja/.emacs
aja
aja

All of which appear correct



> >  emacs --daemon from a terminal errors on ~/.emacs unable to
> > find a font that is specifified,
> 
> Seems to me that you should fix this problem first. Do things work if you
> rename your .emacs?


Of coures -- but now none of my customizations appear.  I should note that, while emacs --daemon throws an error on the font it cannot find, it does launch, albeit without my customizations:

aja@oberon% emacs --daemon                                            ~/Desktop
("emacs")
Loading /usr/share/emacs/site-lisp/site-gentoo.el (source)...
Loading /usr/share/emacs/site-lisp/site-gentoo.el (source)...done
Loading paren...
Loading paren...done
Warning (initialization): An error occurred while loading `/home/aja/.emacs':

error: Font not available, #<font-spec nil nil terminus nil iso8859-* nil nil nil 14.0 nil nil nil ((:name . -*-terminus-*-*-*-*-*-140-*-*-*-*-iso8859-*))>

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.
Starting Emacs daemon.
aja@oberon% emacs --daemon                                            ~/Desktop
("emacs")
Loading /usr/share/emacs/site-lisp/site-gentoo.el (source)...
Another Emacs daemon is already running at process id 10221
Error: server did not start correctly

Notably, even in emacsclient -t, my customizations are no longer functional, so it is likely that .emacs is erroring when starting the /etc/init.d script as well.  This error only occurs in daemon mode (just running `emacs` results in all customizations).



Comment 4 Ulrich Müller gentoo-dev 2009-06-02 07:32:04 UTC
Please attach your .emacs file.
Comment 5 AJ Armstrong 2009-06-02 13:23:06 UTC
Created attachment 193287 [details]
.emacs
Comment 6 Ulrich Müller gentoo-dev 2009-06-02 14:49:27 UTC
The following lines in your .emacs cannot work if you start in daemon mode:
(set-face-font 'menu "-*-terminus-*-*-*-*-*-140-*-*-*-*-iso8859-*")
(set-face-font 'default "-*-terminus-*-*-*-*-*-140-*-*-*-*-iso8859-*")
The reason is that Emacs tries to get the font from the X server, and when you start it as daemon then there is no X connection yet.

You may try to set the face defaults via "M-x customize-face RET" instead, or by setting the corresponding font resource in your .Xresources (or .Xdefaults) file.

Not a Gentoo bug, therefore closing.
Comment 7 AJ Armstrong 2009-06-02 15:21:41 UTC
Actually, we've resolved the "additional info" issue that I added in my first comment, in case it was related.  I accept that it wasn't.  We haven't even discussed the original bug yet.
Comment 8 Ulrich Müller gentoo-dev 2009-06-03 15:18:18 UTC
Maybe this is an xauth problem? What is the value of the XAUTHORITY environment variable:
- in your user shell,
- in a root shell (on Linux console),
- inside the daemonised Emacs (i.e. connect to it with "emacsclient -t" and
  then do "M-x getenv RET XAUTHORITY RET")?
Comment 9 AJ Armstrong 2009-06-03 20:00:01 UTC
(In reply to comment #8)

**Inline**

> Maybe this is an xauth problem? What is the value of the XAUTHORITY environment
> variable:
> - in your user shell,

/tmp/.gdm6XD2UU

> - in a root shell (on Linux console),

/root/.xauthnZzc25

> - inside the daemonised Emacs (i.e. connect to it with "emacsclient -t" and
>   then do "M-x getenv RET XAUTHORITY RET")?

no match

Interesting....


Comment 10 Ulrich Müller gentoo-dev 2009-06-03 20:54:03 UTC
(In reply to comment #9)
> > What is the value of the XAUTHORITY environment variable:
> > - in your user shell,
> /tmp/.gdm6XD2UU

Looks like we've found the reason. GDM sets this to $HOME/.Xauthority for me. Do you assign UserAuthDir=/tmp in your GDM configuration (/etc/X11/gdm/*.conf)?

> > - inside the daemonised Emacs (i.e. connect to it with "emacsclient -t" and
> >   then do "M-x getenv RET XAUTHORITY RET")?
> 
> no match

Which means that the XAUTHORITY variable is unset (which is normal) and defaults to $HOME/.Xauthority. I.e., the real xauth file is in /tmp/ but Emacs expects it in $HOME/.

I don't know if there's a way to fix this. The Emacs daemon may be running before GDM initialises the session, and cannot know which file name GDM will choose for the xauth file (it's probably using mkstemp(3) or similar).
Comment 11 AJ Armstrong 2009-06-03 22:02:24 UTC
No, I'm not setting it anywhere, although GDM will default to /tmp/ if it finds the user's home directory unwriteable.  I don't see why it would find it so...

Will investigate.
Comment 12 AJ Armstrong 2009-06-03 22:43:52 UTC
Heh.  You're not going to believe this one.  Issue was an old ~/.Xauthority that hadn't been cleaned up that was apparently clogging the system.

Resolved.

Thanks, very much, to Ulrich for his patience and assistance in uncovering this.
Comment 13 AJ Armstrong 2009-06-04 00:54:45 UTC
As an aside, for anyone who encounters this bug -- moving the font selection from .emacs to .Xresources does appear to be the solution to this problem.

(In reply to comment #6)
> The following lines in your .emacs cannot work if you start in daemon mode:
> (set-face-font 'menu "-*-terminus-*-*-*-*-*-140-*-*-*-*-iso8859-*")
> (set-face-font 'default "-*-terminus-*-*-*-*-*-140-*-*-*-*-iso8859-*")
> The reason is that Emacs tries to get the font from the X server, and when you
> start it as daemon then there is no X connection yet.
> 
> You may try to set the face defaults via "M-x customize-face RET" instead, or
> by setting the corresponding font resource in your .Xresources (or .Xdefaults)
> file.
> 
> Not a Gentoo bug, therefore closing.
> 

Comment 14 Ulrich Müller gentoo-dev 2009-06-04 05:24:05 UTC
(In reply to comment #12)
> Issue was an old ~/.Xauthority that hadn't been cleaned up that was
> apparently clogging the system.

Makes me wonder if GDM's choice of silently falling back to /tmp is a good solution. IMHO it should better display a message that there is a problem.

Anyway, not a bug of emacs-daemon.