Cimmy

Q: XQuartz and DISPLAY variable

I would greatly appreciate help toward the resolution of an issue that I am having with Mountain Lion (ML) on my 2007 iMac. I like starting X11 applications from a terminal, and it used to be possible until I instaled ML. I understand I have to install XQuartz, log out and  back in, but have done it all several times and I continue to be unable to do it. Specifically, the DISPLAY variable does not get set (output of echo $DISPLAY is just two blank lines).

On the other hand, ifI just start XQuartz and open an xterm I have no problem, i.e., the DISPLAY variable is set normally.

Interestingly, the same procedure works fine on my recently purchased (two weeks) MacBook Air.  Any idea of how I might b able to fix this (I have already gone through the exercise of uninstalling XQuartz and redoing it, I have also rebooted the machine but the problem persists).

Thanks in advance.

iMac, OS X Mountain Lion

Posted on Jul 30, 2012 4:11 PM

Close

Q: XQuartz and DISPLAY variable

  • All replies
  • Helpful answers

Page 1 of 3 last Next
  • by g_wolfman,Helpful

    g_wolfman g_wolfman Jul 30, 2012 4:39 PM in response to Cimmy
    Level 4 (1,141 points)
    Jul 30, 2012 4:39 PM in response to Cimmy

    Not sure what to suggest - I just checked on my installation and I do get a result for "echo $DISPLAY", referring to what looks like a unix socket at (currently) /tmp/launch-31NZS8/org.macosforge.xquartz:0.

     

    I also tried launching Wireshark from the terminal.  The first time I got a dialog asking where X11 was located, but after I pointed it at XQuartz everything worked without a problem.

     

    Have you tried running "launchctl list | grep xquartz" to see if the XQuartz User Launch Agent is actually running?  Perhaps that's the problem.

  • by Cimmy,Helpful

    Cimmy Cimmy Jul 30, 2012 7:05 PM in response to g_wolfman
    Level 1 (0 points)
    Jul 30, 2012 7:05 PM in response to g_wolfman

    It is not. So, I guess that is the problem. Not sure why the same identical procedure sets it up correctly on the MacBook air and not on the iMac, but, there has to be a way to do it manually, I suppose. Thank you, this was helpful.

  • by MrHoffman,

    MrHoffman MrHoffman Jul 31, 2012 6:26 AM in response to Cimmy
    Level 6 (15,612 points)
    Mac OS X
    Jul 31, 2012 6:26 AM in response to Cimmy

    DISPLAY only usually gets set by default when you're in an xterm or other X application.

     

    That's the way the older X Window Server X11.app stuff worked on Lion and prior releases, too.

     

    You won't find that opening Terminal.app will typically get DISPLAY set, for instance.

     

    If you're seeing DISPLAY in a Terminal.app session on one system (but not on another), then check whatever shell scripts are being used to log into bash, and compare those with the system that isn't getting DISPLAY set.  (That's usually the ~/.bash_profile, ~/.bash_login, and ~/.profile scripts, and only one usually gets executed.  For grins, also check the /etc/profile script, but I'd tend to assume the changes weren't there.)  See if, for instance, the XQuartz installation modified one of those scripts, and you're not using that script (but some other login script) in one of your two environments.

  • by BobHarris,

    BobHarris BobHarris Jul 31, 2012 7:09 AM in response to MrHoffman
    Level 6 (19,272 points)
    Mac OS X
    Jul 31, 2012 7:09 AM in response to MrHoffman

    You won't find that opening Terminal.app will typically get DISPLAY set, for instance.

    I think with Leopard, Mac OS X always provided a DISPLAY environment variable, and if something used DISPLAY's contents, X11 would be automatically be started.

     

    Setting DISPLAY in a shell initialization file often messed up X11 on Mac OS X from Leopard onwards.

     

    HOWEVER, I do not have any Mountain Lion experience (yet - I'm going to have to see about downloading a copy and maybe giving it a spin via VMware Fusion -- I do have a flash drive on order so I can have a saved local copy of Mountain Lion installer).

  • by Bill Scott,

    Bill Scott Bill Scott Jul 31, 2012 7:25 AM in response to Cimmy
    Level 6 (11,449 points)
    Jul 31, 2012 7:25 AM in response to Cimmy

    When you install Xquartz, log out, and log in again, it will, forever after, set the $DISPLAY variable automatically for you, as long as you don't try to set it manually somewhere in your shell initialization.

     

    It should look something like the following:

     

    zsh-% print $DISPLAY
    /tmp/launch-vcKJJv/org.macosforge.xquartz:0

     

    So my guess is that there is something clobbering the $DISPLAY.

     

    Try changing your shell, and see if it works (if you have bash, for example, try switching to zsh with   chsh -s /bin/zsh ).  In the unlikely event you would want to switch back from zsh, you can just run the same command for /bin/bash 

  • by Cimmy,

    Cimmy Cimmy Jul 31, 2012 7:31 AM in response to Bill Scott
    Level 1 (0 points)
    Jul 31, 2012 7:31 AM in response to Bill Scott

    When you install Xquartz, log out, and log in again, it will, forever after, set the $DISPLAY variable automatically for you

     

    Except when it does not. I repeat it:

    "I understand I have to install XQuartz, log out and  back in, but have done it all several times and I continue to be unable to do it. "

  • by g_wolfman,

    g_wolfman g_wolfman Jul 31, 2012 7:46 AM in response to Cimmy
    Level 4 (1,141 points)
    Jul 31, 2012 7:46 AM in response to Cimmy

    So like he said, something must be clobbering the $DISPLAY variable.  Or the launchd job isn't running.  For what it's worth, I've just confirmed that the socket is supposed to be launched by a User Launch Agent named org.macosforge.xquart.startx, with the following contents:

     

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

    <plist version="1.0">

    <dict>

              <key>EnableTransactions</key>

              <true/>

              <key>Label</key>

              <string>org.macosforge.xquartz.startx</string>

              <key>ProgramArguments</key>

              <array>

                        <string>/opt/X11/lib/X11/xinit/launchd_startx</string>

                        <string>/opt/X11/bin/startx</string>

                        <string>--</string>

                        <string>/opt/X11/bin/Xquartz</string>

              </array>

              <key>ServiceIPC</key>

              <true/>

              <key>Sockets</key>

              <dict>

                        <key>org.macosforge.xquartz:0</key>

                        <dict>

                                  <key>SecureSocketWithKey</key>

                                  <string>DISPLAY</string>

                        </dict>

              </dict>

    </dict>

    </plist>

     

    So I think the troubleshooting steps should be:

     

    Confirm you have the Launch Agent in the correct location (/Library/LaunchAgents/org.macosforge.xquartz.startx.plist);

    Determine if launchd is running the job (ie, are permissions correct, etc, etc);

    If so, is the job completing successfully (ie, is there a socket at some point);

    If so, when is the socket getting clobbered?

     

    Of course, if it's something in your shell profile clobbering $DISPLAY, then it may be a bit tricky to check the first two without opening a shell...but not impossible.

  • by MrHoffman,

    MrHoffman MrHoffman Jul 31, 2012 12:31 PM in response to BobHarris
    Level 6 (15,612 points)
    Mac OS X
    Jul 31, 2012 12:31 PM in response to BobHarris

    Yeah; my bad; it's not DISPLAY, it's starting up the X server (before the connection arrives) that makes it easiest to launch the ssh -Y from the xterm in my sequences.

  • by Frank Caggiano,

    Frank Caggiano Frank Caggiano Jul 31, 2012 1:44 PM in response to Cimmy
    Level 7 (25,782 points)
    Jul 31, 2012 1:44 PM in response to Cimmy

    You might want to ask over on the Apple X11 mailing list.

  • by Bill Scott,

    Bill Scott Bill Scott Aug 1, 2012 7:58 AM in response to Bill Scott
    Level 6 (11,449 points)
    Aug 1, 2012 7:58 AM in response to Bill Scott

    Again, try changing your shell, or, alternatively, create a new test account, and see if it works from that.  If so, you know it is something in your own account's configuration files.

  • by nmt1900,

    nmt1900 nmt1900 Aug 12, 2012 6:36 AM in response to Bill Scott
    Level 1 (0 points)
    Aug 12, 2012 6:36 AM in response to Bill Scott

    I am having the same problem and it looks like the problem is in userspace, because everything is correct under new user. Now I am just at loss here, how to correct things under current user, because the most obvious things like .bashrc, .bash_profile, .profile are all checked through and even thrashed once without any result.

     

    It looks like moving my stuff under new user could be smarter move...

  • by BobHarris,

    BobHarris BobHarris Aug 12, 2012 9:43 AM in response to nmt1900
    Level 6 (19,272 points)
    Mac OS X
    Aug 12, 2012 9:43 AM in response to nmt1900

    What does your DISPLAY environment variable look like:

     

    echo $DISPLAY

     

    Does it look something like this:

     

    /tmp/launch-egVRmr/org.x:0

     

    The important thing being does it start with /tmp and end in colon 0 (I can't actually type : 0 as adjacent characters, as the forum thinks I'm putting in a smilie )

     

    AND does the file exist in /tmp/mumble/somthing ?

     

    If not, then you might also check if you created a $HOME/.MacOSX/environment.plist which is another way to customize the user's environment (EXCEPT on Mountain Lion where this has been discontinued).

     

    Is ssh involved?  In that .ssh/config can have setup information, which can affect logging into remote systems.

     

    Are you having the problem connecting to a remote system and exporting your display back to the Mac?  That could possibily be an issue with the remote system's shell initialization files.

     

    Can you give us more information to work with?

  • by nmt1900,

    nmt1900 nmt1900 Aug 12, 2012 10:27 AM in response to BobHarris
    Level 1 (0 points)
    Aug 12, 2012 10:27 AM in response to BobHarris

    It looks like it should under new user ("/tmp/launch-egVRmr/org.x:0"-ish), but under my current user I get only an empty line as answer to echo $DISPLAY.

     

    Switching the shell to zshell does not change anything - still the same empty line.

     

    When I am logged in as new user, wireshark and other X11 applications will bring XQuartz up and everything works as it should.

     

    On my current user there is no way to bring XQuartz up by other application and when this is tried from command line, then only answer is "cannot open display".

     

    Removing and reinstalling XQuartz does nothing - which is obvious, because the problem does not seem to be on system level.

     

    I have been trying to compare the files in LaunchAgents and other possible places between my current user and new one and have not find anything helpful.

     

    I have not been logging into remote systems lately so I cannot say anything about that. Current user does not seem to have .ssh_config file and system-level ssh_config has XAuthLocation line added by XQuartz.

     

    I do not have anything in  $HOME/.MacOSX/ folder. No custom xinit files either.Have macports installed, but not X11 from there.

     

    Wineskin Winery is installed and wineskin apps work without problem.

  • by nmt1900,

    nmt1900 nmt1900 Aug 12, 2012 10:43 AM in response to nmt1900
    Level 1 (0 points)
    Aug 12, 2012 10:43 AM in response to nmt1900

    It seems like posts cannot be edited here after some (not very long) timeout so I have to add this here - there is no org.x:0 file anywhere in /tmp either.

Page 1 of 3 last Next