0

I'm having trouble with XQuartz on Mavericks. After I went to apple genius support to change my battery (in which the genius guy forced power off when I had an X11 connection opened), I am having the following crash when I try to open XQuartz:

*** The application X11 could not be opened. ***
An error occurred while starting the X11 server: "Cannot establish any listening sockets - Make sure an X server isn't already running"
Click Quit to quit X11. Click Report to see more details or send a report to Apple.

I've tried to make a clean install of the XQuartz by doing:

launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz
sudo pkgutil —forget org.macosforge.xquartz.pkg

And then installed XQuartz latest version (in actual date it is this one). Log-out, log-in, no success.

I also tried deleting /private/tmp/.X* files, /private/tmp/launch-* folders which contained xquartz displays and also the .Xauthority file in the $HOME directory.

Since this didn't work, I've struggled to use the port xorg-server X11, using sudo port install xorg-server after uninstalling XQuartz. I also had to make it active using launchctl load -w /Library/LaunchAgents/org.macports.startx.plist(found here) and also used sudo port -f deactivate xinit && sudo port activate xinit (found here).

Unfortunately it didn't work also (I got an error on the server saying it had not permissions to open the $DISPLAY on my local machine).

Other treads in superuser talking about the similar issue:

  1. Issue on mavericks, no answer on this topic.
  2. Issue on snowleopard: I need to redo this launchctl load -w again paying attention to the sudo tip which I didn't know about.

I have tried every combination possible and exhausted searching the internet for possibilities. I am dead in the water here guys , any ideas?

1
  • I've created a ticket on Xquartz: 2073
    – Werner
    Nov 26, 2014 at 11:53

2 Answers 2

2

As reported in ticket 589, this can happen due to bugs in your shell init scripts.

As reported in ticket 685, this can happen if you replace /usr/bin/mktemp with an incompatible version (eg: GNU mktemp).

11
  • Thank you for your answer (although it seems more like a comment). I've followed 685 and with the ticket I've created (2073), I've discovered that if I do —> sudo /usr/bin/mktemp -d /tmp/tempdir I get: /usr/bin/mktemp: too few X's in template '/tmp/tempdir', whereas my default system mktemp, which is —> which mktemp: /sw/sbin/mktemp, gives no error: —> sudo /sw/sbin/mktemp -d /tmp/tempdir: /tmp/tempdir
    – Werner
    Nov 26, 2014 at 11:56
  • Linking the /usr/bin/mktemp to /sw/sbin/mktemp looked like to solve the issue of Xquartz opening. I am having permission issues, however: when I log into a server which wants to open a X11 window, I get a message: connect /tmp/launch-zmVJjw/org.macports:0: Permission denied
    – Werner
    Nov 26, 2014 at 13:09
  • Ok, in fact the /sw/sbin/mktemp is from port xorg-server…
    – Werner
    Nov 26, 2014 at 15:44
  • As I will mention in the ticket when MacPorts is back online, you replaced the system mktemp with a 3rd party one. That caused the problem. The permissions issues are unrelated. /sw/sbin/mktemp is NOT from the xorg-server port. You installed that with fink. The perms issue is likely because you uninstalled the xinit port. Nov 26, 2014 at 17:17
  • I see… sorry, I didn't know that the mktemp was supposed to be from Xquartz or from xorg-server port. But how can I manage to make either of those X11 to work?
    – Werner
    Nov 26, 2014 at 17:46
0

Today I had time to look again into this, and what is funny though is that I don't even needed to have the original mktemp available on /usr/bin/mktemp path (you shouldn't do this, this is only to illustrate that the previous discussion about the mktemp binary had nothing to do with the issue):

`--> ls /usr/bin/mktemp
ls: cannot access /usr/bin/mktemp: No such file or directory

my issue was probably the installation of port xquartz together with the original xquartz. I made a complete uninstall on both clients:

sudo port uninstall xinit xorg-server

And for the "original" xquartz (info here, look for "Uninstall (Snow Leopard or Later)"):

launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz
sudo pkgutil --forget org.macosforge.xquartz.pkg

Some of those may fail since the port uninstallation may deactivate those, you can ignore those fails.

This is important. In my previous attempts, I was failing probably because I wouldn't restart my account, which seems that is needed in order to the launchctl to make effect (I might be wrong over here, but anyway, it is important for you to logout and login your account for the installation changes to take effect).

With the clean environment, now install the XQuartz, log-out, log-in and it should work. If not, take a look in the following debug instructions from XQuartz, look for "ssh X forwarding debugging":

[1] local $ echo $DISPLAY
/tmp/launch-Bh0fLm/:0
[2] local $ grep DISPLAY ~/.*rc ~/.login ~/.*profile ~/.MacOSX/environment.plist 2>/dev/null
[3] local $ grep -r DISPLAY /opt/local/etc /sw/etc /etc 2>/dev/null
[4] local $ ssh -Y remote
Warning: No xauth data; using fake authentication data for X11 forwarding.
[5] remote $ echo $DISPLAY
localhost:10.0
[6] remote $ grep X11 /etc/ssh/sshd_config ~/.ssh/*
X11Forwarding yes
X11DisplayOffset 10

My issue started on the first line, where the DISPLAY variable was empty. I would run commands 2 and 3, and there was nothing changing it, so I new there the problem was something with the launchtcl, and had nothing to do with steps 4 and afterwards. But your case could be different, so follow this debug instructions to check what your problem may be.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .