Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#63990 closed defect (fixed)

xorg-server and DISPLAY

Reported by: haberg-1 (Hans Åberg) Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: monterey Cc: jeremyhu (Jeremy Huddleston Sequoia), ferdy (Giuseppe `ferdy` Miceli), cjones051073 (Chris Jones)
Port: xorg-server

Description

For use with xorg-server on MacOS 12, contrary to what is said in [1], the DISPLAY variable must be set. Testing works with: DISPLAY=:0 or DISPLAY=:0.0 However, after 'unset DISPLAY', for example 'xeyes' gives: Error: Can't open display:

  1. https://guide.macports.org

Change History (28)

comment:1 Changed 3 years ago by jmroot (Joshua Root)

Cc: jeremyhu added; jeremyhu@… removed

I can't speak for Monterey specifically, but typically DISPLAY should be a path like /private/tmp/com.apple.launchd.XFNmGzTgze/org.xquartz:0. The xinit port is responsible for loading /Library/LaunchDaemons/org.macports.privileged_startx.plist which should create the socket. I don't think the xorg ports changed in this respect recently. Do you have any other X server installed?

comment:2 Changed 3 years ago by haberg-1 (Hans Åberg)

I removed the XQuartz.app according to the instructions at https://gist.github.com/pwnsdx/d127873e24cef159d4d603accaf37ee4

There is /private/tmp/com.apple.launchd.nDro5hTUYP/org.xquartz:0, but setting DISPLAY to that does not work, that is, nothing happens with for example 'xeyes', even no error. The value DISPLAY=:0 works. (The X11 app is open when trying.) The file /Library/LaunchDaemons/org.macports.privileged_startx.plist exists. So it is not a socket loading issue, it seems.

comment:3 Changed 3 years ago by ferdy (Giuseppe `ferdy` Miceli)

Cc: ferdy added

comment:4 Changed 3 years ago by cjones051073 (Chris Jones)

Indeed, the X11 server is no longer automatically starting for me too. It was working just fine last time I used it, probably only a few days ago, so something has caused this recently...

comment:5 Changed 3 years ago by Chris Jones <jonesc@…>

comment:6 Changed 3 years ago by cjones051073 (Chris Jones)

OK, it seems for some reason xinit needed a rev-bump. Presumably after some dependency update that wasn't automatically handled via the usual rev-upgrade.

With the above xorg-server again behaves as expected, automatically starting as required.

Last edited 3 years ago by cjones051073 (Chris Jones) (previous) (diff)

comment:7 Changed 3 years ago by cjones051073 (Chris Jones)

Cc: cjones051073 added

comment:8 Changed 3 years ago by haberg-1 (Hans Åberg)

As for the DISPLAY issue, the items put in the X11 menu "Applications" work, so you might check what it uses. In addition, one must typically add LANG=en_US or LANG=en_US.UTF-8, because MacOS only has LC_CTYPE=UTF-8, and a number of Unix programs do not support this. I have checked on the UNIX/POSIX (Austin Group) standardization list that LC_CTYPE=UTF-8 is confirming. (Copy and paste do not work in this menu, so one has to write these complicated commands by hand.)

The XQuartz app got broken so it did not help putting this in the menu, for example xboard ends up with French menus. (The program xboard can be run using the stockfish engine via polyglot, but some reason, these two latter programs are not in MacPorts.)

comment:9 Changed 3 years ago by haberg-1 (Hans Åberg)

If I quit the X11 app and runs 'xeyes' then I get Error: Can't open display: :0

So this suggests that what is expected is DISPLAY=:0.

comment:10 Changed 3 years ago by cjones051073 (Chris Jones)

No, you should never have to set DISPLAY yourself.

comment:11 Changed 3 years ago by cjones051073 (Chris Jones)

Oberon ~/Projects/MacPorts/ports > echo $DISPLAY
/private/tmp/com.apple.launchd.0x418KzNp3/org.macports:0
Oberon ~/Projects/MacPorts/ports > xeyes        

X11 server automatically starts and xeyes displays. Thats the correct and expected behaviour.

comment:12 Changed 3 years ago by cjones051073 (Chris Jones)

b.t.w. what X11 server are you using ? Is it the macports provided one via the xorg-server port ?

comment:13 Changed 3 years ago by haberg-1 (Hans Åberg)

Then you will have to change something to accommodate for that. —As it is now, it must be set.

I think DISPLAY=:0 is the default name, so perhaps there has been a change in the xorg-server sources.

comment:14 Changed 3 years ago by haberg-1 (Hans Åberg)

Yes, it is all about the xorg-server port. I had the XQuartz app, but all its components have been removed as per the link I gave above.

comment:15 Changed 3 years ago by cjones051073 (Chris Jones)

No, DISPLAY does not need to be set.

DISPLAY=:0 has not been the correct way to configure things on macOS for a long long time. Ever since XQuartz has been around it has used the form /private/tmp/com.apple.launchd.0x418KzNp3/org.macports:

Last edited 3 years ago by cjones051073 (Chris Jones) (previous) (diff)

comment:16 Changed 3 years ago by haberg-1 (Hans Åberg)

In addition, following a suggestion, I used 'port -f uninstall xinit; port install xinit' with logout/reboot a number of times.

comment:17 Changed 3 years ago by cjones051073 (Chris Jones)

Please make sure you are running the xinit fix.

Oberon ~/Projects/MacPorts/ports > port installed | grep xinit
  xinit @1.4.1_1 (active)

If you do not have precisely the version above, update your ports

sudo port sync
sudo port upgrade outdated
Last edited 3 years ago by cjones051073 (Chris Jones) (previous) (diff)

comment:18 in reply to:  16 Changed 3 years ago by cjones051073 (Chris Jones)

Replying to haberg-1:

In addition, following a suggestion, I used 'port -f uninstall xinit; port install xinit' with logout/reboot a number of times.

That would have reinstalled the previous binary xinit tarball, which will not help. You need a rebuild.

comment:19 Changed 3 years ago by haberg-1 (Hans Åberg)

There are /private/tmp/com.apple.launchd.nDro5hTUYP/org.xquartz:0 /private/tmp/com.apple.launchd.z8pZ6R48KZ/org.macports:0

Should the first be removed?

comment:20 Changed 3 years ago by haberg-1 (Hans Åberg)

I do not get a rebuild after port sync; port upgrade outdated, though. Perhaps the changes have not come downstream yet?

comment:21 Changed 3 years ago by cjones051073 (Chris Jones)

You should never have to manually fiddle with any of those yourself, so leave be.

  1. make sure you have the updated xinit version
  2. make sure you do not set DISPLAY anywhere yourself
  3. Log out and in again
  4. Confirm DISPLAY is then set to the correct socket form, as above
  5. see if running xeyes etc. automatically starts the server as required.
Last edited 3 years ago by cjones051073 (Chris Jones) (previous) (diff)

comment:22 in reply to:  20 Changed 3 years ago by cjones051073 (Chris Jones)

Replying to haberg-1:

I do not get a rebuild after port sync; port upgrade outdated, though. Perhaps the changes have not come downstream yet?

maybe. You can force a rebuild from source yourself with

sudo port -f uninstall xinit
sudo port -s install xinit

comment:23 Changed 3 years ago by haberg-1 (Hans Åberg)

I have found the problem, I think:

There is a file .zprofile added by the MacPorts installer, with the contents below. It adds DISPLAY=:0, and then the automatic launch of the X11 app does not work. If I set export DISPLAY=/private/tmp/com.apple.launchd.z8pZ6R48KZ/org.macports:0 then 'eyes' will launch even if the X11 app is not open.

If I move the .zprofile to another name, then it will set DISPLAY=/private/tmp/com.apple.launchd.nDro5hTUYP/org.xquartz:0 and the xeyes will not open regardless if X11 is open.

I might add that I do no like the clandestine addition of .zprofile that the MacPorts installer makes, because I have the environment defined in .profile, which is then I call from .zshrc.

  • .zprofile

# MacPorts Installer addition on 2020-11-15_at_10:14:24: adding an appropriate PATH variable for use with MacPorts. export PATH="/opt/local/bin:/opt/local/sbin:$PATH" # Finished adapting your PATH environment variable for use with MacPorts.

# MacPorts Installer addition on 2020-11-15_at_10:14:24: adding an appropriate DISPLAY variable for use with MacPorts. export DISPLAY=:0 # Finished adapting your DISPLAY environment variable for use with MacPorts. -

comment:24 Changed 3 years ago by cjones051073 (Chris Jones)

There was a bug in an old base installer that added DISPLAY=:0 when it should not have. If you see this in your config files remove it.

DO NOT though manually set DISPLAY to anything else. This is NOT REQUIRED and it will be set for you when you start a new shell. The exact socket path changes each login so what works in one shell might not in another.

Last edited 3 years ago by cjones051073 (Chris Jones) (previous) (diff)

comment:25 Changed 3 years ago by haberg-1 (Hans Åberg)

The update of xinit arrived, but it did not help: DISPLAY is set to org.xquartz:0, and not org.macports:0, also after logout/login and also reboot.

comment:26 Changed 3 years ago by cjones051073 (Chris Jones)

That must mean you have some residual of a non-MacPorts version of XQuartz still installed that is interfering. You need to make sure you have completely removed it.

Also, maybe try removing and re-installing xorg-server, followed by another logout and login.

Last edited 3 years ago by cjones051073 (Chris Jones) (previous) (diff)

comment:27 Changed 3 years ago by haberg-1 (Hans Åberg)

Now, the DISPLAY variable is set to the org.macports:0 file, as it should be, and X11 starts when issuing an command from Terminal:

Indeed, there were stuff from XQuartz remaining, the instructions that I followed, as indicated above, have "macosforge" in the name. So worked that list with that part removed; these are included below for the record. Then I rebooted, to make sure any stray daemons are killed off.

Before I did that, the org.xquartz:0 was recreated when rebooting, and the DISPLAY variable set to it.

  • Remove XQuartz
    rm /Library/LaunchAgents/org.xquartz.startx.plist
    rm /Library/LaunchDaemons/org.xquartz.privileged_startx.plist
    rm -rf /opt/X11*
    /etc/*paths.d/*XQuartz
    ~/.Xauthorit*
    rm -r ~/.cache
    rm -r ~/Library/Caches/org.xquartz.X11
    rm -r ~/Library/Logs/X11
    rm /private/tmp/com.apple.launchd.Ia0BLlKp5F/org.xquartz:0
    rmdir /private/tmp/com.apple.launchd.Ia0BLlKp5F/
    
Last edited 3 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:28 Changed 3 years ago by cjones051073 (Chris Jones)

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.