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?

Werner
  • 225
  • 2
  • 15

2 Answers2

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).

  • Thank you for your answer (although it seems more like a comment). I've followed 685 and with the ticket I've created ([2073](http://xquartz.macosforge.org/trac/ticket/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 '14 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 '14 at 13:09
  • Ok, in fact the `/sw/sbin/mktemp` is from port xorg-server… – Werner Nov 26 '14 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. – Jeremy Huddleston Sequoia Nov 26 '14 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 '14 at 17:46
  • /usr/bin/mktemp is provided by Apple in OS X. You replaced it with a 3rd party binary. The only thing I can recommend is that you re-install your OS because you have corrupted it. Don't replace system executables and libraries if you don't understand the consequences. In this case, the consequence of replacing /usr/bin/mktemp with an incompatible version was that things relying on it (like XQuartz) no longer function. – Jeremy Huddleston Sequoia Nov 26 '14 at 21:54
  • If you want, you can just replace /usr/bin/mktemp with a valid version, but I have no idea what else you've replaced in /usr/bin with incompatible versions, so it's safer to just re-install and make sure you don't corrupt your system in the future. – Jeremy Huddleston Sequoia Nov 26 '14 at 21:55
  • I havent replaced x). I've just moved it and created a link on its place. I've created a link to the original system file afterwards I discovered and u warned me that I couldnt do this.... – Werner Nov 26 '14 at 21:56
  • I have not replaced anything else, I try to keep track of my changes (specially when sudoing) as hard as I can. – Werner Nov 26 '14 at 22:00
  • The issue you are reporting was *caused* by your replacing /usr/bin/mktemp. You *later* replaced it with a symlink to /sw/bin/mktemp, but the version that was there *prior* to your symlink (the one with uuid C0FE4B3B-A5F2-35A6-A70F-8AD477BCA31C) was not the one that was shipped with your OS (ie, you did something to replace it with a non-Apple version). – Jeremy Huddleston Sequoia Nov 26 '14 at 22:03
  • I see... sorry for the misunderstood, the linking of the same file got me confused. I want to thank you for helping me. I will try to use time machine to return to a point where this error would not happen. – Werner Nov 26 '14 at 22:10
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.

Werner
  • 225
  • 2
  • 15