Opened 3 months ago

Last modified 2 months ago

#61649 assigned defect

installer postflight incorrectly sets DISPLAY variable on Big Sur

Reported by: collamaf Owned by: jeremyhu (Jeremy Huddleston Sequoia)
Priority: Normal Milestone:
Component: base Version: 2.6.4
Keywords: bigsur Cc: cjones051073 (Chris Jones), MaddTheSane (C.W. Betts), rsmacleod (Rob MacLeod)
Port:

Description

Hello Fresh installation of Big Sur and MacPorts.

I did sudo port -v install xorg-server xorg

Log out, login (then also several reboots), but Big Sur does not seem to have the DISPLAY variable set, so for example :

√ ~ % echo $DISPLAY
:0
√ ~ % xterm
xterm: Xt error: Can't open display: :0

If I manually open Applications/MacPorts/X11 then xterm opens, but it does not work automatically on startup

I also tried to manually activate the daemon, with no luck:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.privileged_startx.plist

sudo launchctl load -w /Library/LaunchAgents/org.macports.startx.plist

Am I doing something wrong?

Attachments (1)

Schermata 2020-12-03 alle 11.13.06.png (94.7 KB) - added by collamaf 3 months ago.

Download all attachments as: .zip

Change History (42)

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

Owner: set to jeremyhu
Port: xinit added; xorg removed
Status: newassigned

LaunchAgents are not meant to be loaded as root, but this should still just work automatically.

comment:2 Changed 3 months ago by cjones051073 (Chris Jones)

works fine for me

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

are you sure you are not setting this manually yourself somewhere ?

comment:3 Changed 3 months ago by cjones051073 (Chris Jones)

Cc: cjones051073 added

comment:4 Changed 3 months ago by eabolden (Eric Bolden)

I am seeing the same issue on a Mac mini (M1, 2020) running macOS 11.0.1 20B29. I set /Applications/MacPorts/X11.app to open on login to work around the issue for now.

comment:5 Changed 3 months ago by cjones051073 (Chris Jones)

Is the OP using M1 or Intel machines ?

comment:6 in reply to:  5 Changed 3 months ago by collamaf

Replying to cjones051073:

Is the OP using M1 or Intel machines ?

Hi, Intel

comment:7 in reply to:  2 Changed 3 months ago by collamaf

Replying to cjones051073:

works fine for me

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

are you sure you are not setting this manually yourself somewhere ?

As far as I could control in my .zsrch file there is no other setting of that variable..

comment:8 Changed 3 months ago by cjones051073 (Chris Jones)

Do you actually have the files

/Library/LaunchAgents/org.macports.startx.plist
/Library/LaunchDaemons/org.macports.privileged_startx.plist

on your system ?

Changed 3 months ago by collamaf

comment:9 in reply to:  8 Changed 3 months ago by collamaf

Replying to cjones051073:

Do you actually have the files

/Library/LaunchAgents/org.macports.startx.plist
/Library/LaunchDaemons/org.macports.privileged_startx.plist

on your system ?

Yes, to both (see attached image)

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

what does

 > launchctl list | grep macports 
-	0	org.macports.startx

give you ?

( and please don't use pngs to post text results back. Just cut and past them into the reply .... )

comment:11 in reply to:  10 Changed 3 months ago by collamaf

Replying to cjones051073:

what does

 > launchctl list | grep macports 
-	0	org.macports.startx

give you ?

( and please don't use pngs to post text results back. Just cut and past them into the reply .... )

% launchctl list | grep macports
36940	0	application.org.macports.X11.10196164.10196161
-	0	org.macports.startx

(sorry for the .png!)

Last edited 3 months ago by ryandesign (Ryan Schmidt) (previous) (diff)

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

b.t.w. - To send verbatim text enclose it inside triple braces {{{ }}}

Last edited 3 months ago by ryandesign (Ryan Schmidt) (previous) (diff)

comment:13 Changed 3 months ago by cjones051073 (Chris Jones)

OK. So progress. you appear to have an additional entry there I do not have.

36940 0 application.org.macports.X11.10196164.10196161

I suspect the reason why that is there is probably part of the problem. Can you try and locate the plot file it relates to and see what it is ?

comment:14 Changed 3 months ago by cjones051073 (Chris Jones)

note the first number there indicates the process is running as its the PID. Can you also run

ps x | grep 36940

to see what it is ?

comment:15 in reply to:  14 Changed 3 months ago by collamaf

Replying to cjones051073:

note the first number there indicates the process is running as its the PID. Can you also run

ps x | grep 36940

to see what it is ?

ps x | grep 36940
36940   ??  S     21:13.87 /Applications/MacPorts/X11.app/Contents/MacOS/X11.bin
39139 s007  S+     0:00.00 grep 36940

comment:16 Changed 3 months ago by cjones051073 (Chris Jones)

can you shutdown X11 app then try again.

Also, what does

 > ls -1 /Library/Launch*/*macports*
/Library/LaunchAgents/org.macports.startx.plist
/Library/LaunchDaemons/org.macports.mpstats.plist
/Library/LaunchDaemons/org.macports.privileged_startx.plist
/Library/LaunchDaemons/org.macports.rsyncd.plist
/Library/LaunchDaemons/org.macports.slapd.plist

give you ?

comment:17 in reply to:  16 ; Changed 3 months ago by collamaf

Replying to cjones051073:

can you shutdown X11 app then try again.

Also, what does

 > ls -1 /Library/Launch*/*macports*
/Library/LaunchAgents/org.macports.startx.plist
/Library/LaunchDaemons/org.macports.mpstats.plist
/Library/LaunchDaemons/org.macports.privileged_startx.plist
/Library/LaunchDaemons/org.macports.rsyncd.plist
/Library/LaunchDaemons/org.macports.slapd.plist

give you ?

Closed X11, now obviously

ps x | grep 36940
39164 s007  S+     0:00.00 grep 36940
% ls -1 /Library/Launch*/*macports*
/Library/LaunchAgents/org.macports.startx.plist
/Library/LaunchDaemons/org.macports.privileged_startx.plist

comment:18 in reply to:  17 ; Changed 3 months ago by cjones051073 (Chris Jones)

Replying to collamaf:

Replying to cjones051073:

can you shutdown X11 app then try again.

Also, what does

 > ls -1 /Library/Launch*/*macports*
/Library/LaunchAgents/org.macports.startx.plist
/Library/LaunchDaemons/org.macports.mpstats.plist
/Library/LaunchDaemons/org.macports.privileged_startx.plist
/Library/LaunchDaemons/org.macports.rsyncd.plist
/Library/LaunchDaemons/org.macports.slapd.plist

give you ?

Closed X11, now obviously

ps x | grep 36940
39164 s007  S+     0:00.00 grep 36940

well yes. but what does launhctl now list ?

% ls -1 /Library/Launch*/*macports*
/Library/LaunchAgents/org.macports.startx.plist
/Library/LaunchDaemons/org.macports.privileged_startx.plist

comment:19 in reply to:  18 Changed 3 months ago by collamaf

Replying to cjones051073:

Replying to collamaf:

Replying to cjones051073:

can you shutdown X11 app then try again.

Also, what does

 > ls -1 /Library/Launch*/*macports*
/Library/LaunchAgents/org.macports.startx.plist
/Library/LaunchDaemons/org.macports.mpstats.plist
/Library/LaunchDaemons/org.macports.privileged_startx.plist
/Library/LaunchDaemons/org.macports.rsyncd.plist
/Library/LaunchDaemons/org.macports.slapd.plist

give you ?

Closed X11, now obviously

ps x | grep 36940
39164 s007  S+     0:00.00 grep 36940

well yes. but what does launhctl now list ?

% ls -1 /Library/Launch*/*macports*
/Library/LaunchAgents/org.macports.startx.plist
/Library/LaunchDaemons/org.macports.privileged_startx.plist

oh sure, I pasted the wrong one!

launchctl list | grep macports 
-	0	org.macports.startx

comment:20 Changed 3 months ago by cjones051073 (Chris Jones)

OK thanks. I don't see the same entry as you, but thats probably because I started X11 via the DISPLAY socket, which works fine for me, I guess.

So, bottom line is the same. I really don't see why your DISPLAY would be set to :0

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

can you just for completeness post what is in both those two plist files. e.g.

Oberon ~/Projects/MacPorts/ports > cat /Library/LaunchAgents/org.macports.startx.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
		<string>org.macports.startx</string>
	<key>ProgramArguments</key>
		<array>
			<string>/opt/local/libexec/launchd_startx</string>
			<string>/opt/local/bin/startx</string>
		</array>
	<key>Sockets</key>
		<dict>
			<key>org.macports:0</key>
				<dict>
					<key>SecureSocketWithKey</key>
						<string>DISPLAY</string>
				</dict>
		</dict>
	<key>ServiceIPC</key>
		<true/>
	<key>EnableTransactions</key>
		<true/>
</dict>
</plist>
Oberon ~/Projects/MacPorts/ports > cat /Library/LaunchDaemons/org.macports.privileged_startx.plist
<?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>Label</key>
		<string>org.macports.privileged_startx</string>
	<key>ProgramArguments</key>
		<array>
			<string>/opt/local/libexec/privileged_startx</string>
			<string>-d</string>
			<string>/opt/local/etc/X11/xinit/privileged_startx.d</string>
		</array>
	<key>MachServices</key>
		<dict>
			<key>org.macports.privileged_startx</key>
				<true/>
		</dict>
	<key>TimeOut</key>
		<integer>120</integer>
	<key>EnableTransactions</key>
		<true/>
</dict>
</plist>

do they look the same ?

comment:22 in reply to:  21 Changed 3 months ago by collamaf

Replying to cjones051073:

can you just for completeness post what is in both those two plist files. e.g.

Oberon ~/Projects/MacPorts/ports > cat /Library/LaunchAgents/org.macports.startx.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
		<string>org.macports.startx</string>
	<key>ProgramArguments</key>
		<array>
			<string>/opt/local/libexec/launchd_startx</string>
			<string>/opt/local/bin/startx</string>
		</array>
	<key>Sockets</key>
		<dict>
			<key>org.macports:0</key>
				<dict>
					<key>SecureSocketWithKey</key>
						<string>DISPLAY</string>
				</dict>
		</dict>
	<key>ServiceIPC</key>
		<true/>
	<key>EnableTransactions</key>
		<true/>
</dict>
</plist>
Oberon ~/Projects/MacPorts/ports > cat /Library/LaunchDaemons/org.macports.privileged_startx.plist
<?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>Label</key>
		<string>org.macports.privileged_startx</string>
	<key>ProgramArguments</key>
		<array>
			<string>/opt/local/libexec/privileged_startx</string>
			<string>-d</string>
			<string>/opt/local/etc/X11/xinit/privileged_startx.d</string>
		</array>
	<key>MachServices</key>
		<dict>
			<key>org.macports.privileged_startx</key>
				<true/>
		</dict>
	<key>TimeOut</key>
		<integer>120</integer>
	<key>EnableTransactions</key>
		<true/>
</dict>
</plist>

do they look the same ?

 cat /Library/LaunchAgents/org.macports.startx.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
		<string>org.macports.startx</string>
	<key>ProgramArguments</key>
		<array>
			<string>/opt/local/libexec/launchd_startx</string>
			<string>/opt/local/bin/startx</string>
		</array>
	<key>Sockets</key>
		<dict>
			<key>org.macports:0</key>
				<dict>
					<key>SecureSocketWithKey</key>
						<string>DISPLAY</string>
				</dict>
		</dict>
	<key>ServiceIPC</key>
		<true/>
	<key>EnableTransactions</key>
		<true/>
</dict>
</plist>



cat /Library/LaunchDaemons/org.macports.privileged_startx.plist
<?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>Label</key>
		<string>org.macports.privileged_startx</string>
	<key>ProgramArguments</key>
		<array>
			<string>/opt/local/libexec/privileged_startx</string>
			<string>-d</string>
			<string>/opt/local/etc/X11/xinit/privileged_startx.d</string>
		</array>
	<key>MachServices</key>
		<dict>
			<key>org.macports.privileged_startx</key>
				<true/>
		</dict>
	<key>TimeOut</key>
		<integer>120</integer>
	<key>EnableTransactions</key>
		<true/>
</dict>
</plist>

comment:23 Changed 3 months ago by cjones051073 (Chris Jones)

Can you try creating a new test user on your system, logout and then login as that new user, and see how things look there ?

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

comment:24 in reply to:  23 Changed 3 months ago by collamaf

Replying to cjones051073:

Can you try creating a new test user on your system, logout and then login as that new user, and see how things look there ?

Thanks for the suggestion. I will do it ASAP (today). Just to be sure: just creating the user, no port actions?

comment:25 Changed 3 months ago by cjones051073 (Chris Jones)

yep, no port actions. just log in as the new user and see if X11 works as expected there or not.

comment:26 in reply to:  25 Changed 3 months ago by collamaf

Replying to cjones051073:

yep, no port actions. just log in as the new user and see if X11 works as expected there or not.

I just tried to create the new user, and indeed the DISPLAY variable is correctly set, and X11 seems to work.. Any idea what can be wrong with my main account? There should be someone somewhere setting the variable? thanks!

comment:27 Changed 3 months ago by cjones051073 (Chris Jones)

Yes, something in your account is setting DISPLAY when it shouldn't. you need to find this and remove it.

  • Does grep DISPLAY ~/.* show anything ?
  • If not, you need to go through all your login scripts (~/.profile, ~/.zshrc etc.) and see if there is anything you are doing there that could be (indirectly) setting this. Do you source anything external ?
  • What terminal emulator application are you using ? Try searching the preferences for that to see if you are doing anything there.
Last edited 3 months ago by cjones051073 (Chris Jones) (previous) (diff)

comment:28 in reply to:  27 ; Changed 3 months ago by collamaf

Replying to cjones051073:

Yes, something in your account is setting DISPLAY when it shouldn't. you need to find this and remove it.

  • Does grep DISPLAY ~/.* show anything ?
  • If not, you need to go through all your login scripts (~/.profile, ~/.zshrc etc.) and see if there is anything you are doing there that could be (indirectly) setting this. Do you source anything external ?
  • What terminal emulator application are you using ? Try searching the preferences for that to see if you are doing anything there.

ok, I will go through these possibilities. For now, the grep command gives this output:

/Users/user/.zprofile:# MacPorts Installer addition on 2020-11-15_at_16:10:30: adding an appropriate DISPLAY variable for use with MacPorts.
/Users/user/.zprofile:export DISPLAY=:0
/Users/user/.zprofile:# Finished adapting your DISPLAY environment variable for use with MacPorts.

is it normal?

Last edited 3 months ago by collamaf (previous) (diff)

comment:29 in reply to:  28 Changed 3 months ago by cjones051073 (Chris Jones)

Replying to collamaf:

Replying to cjones051073:

Yes, something in your account is setting DISPLAY when it shouldn't. you need to find this and remove it.

  • Does grep DISPLAY ~/.* show anything ?
  • If not, you need to go through all your login scripts (~/.profile, ~/.zshrc etc.) and see if there is anything you are doing there that could be (indirectly) setting this. Do you source anything external ?
  • What terminal emulator application are you using ? Try searching the preferences for that to see if you are doing anything there.

ok, I will go through these possibilities. For now, the grep command gives this output:

/Users/chicco/.zprofile:# MacPorts Installer addition on 2020-11-15_at_16:10:30: adding an appropriate DISPLAY variable for use with MacPorts.
/Users/chicco/.zprofile:export DISPLAY=:0
/Users/chicco/.zprofile:# Finished adapting your DISPLAY environment variable for use with MacPorts.

is it normal?

No, whatever is doing the above shouldn't be doing it....

comment:30 Changed 3 months ago by cjones051073 (Chris Jones)

Oberon ~/Projects/MacPorts/ports > git grep "Finished adapting your"
science/arb/files/arb_macsetup:    echo -e "# Finished adapting your ${1} environment variable for use with ARB.\n" >> ${HOME}/.${CONF_FILE}

have you by chance installed arb ?

comment:31 Changed 3 months ago by cjones051073 (Chris Jones)

Hmmm. looks like base is doing this. no idea why ....

Oberon ~/Projects/MacPorts/base > git grep "Finished adapting your"
portmgr/dmg/postflight.in:        echo -e "# Finished adapting your ${1} environment variable for use with MacPorts.\n"

remove it. Setting DISPLAY to :0 is just wrong and breaks the socket based approach used by the X11 server.

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

comment:32 Changed 3 months ago by cjones051073 (Chris Jones)

OK, I see what is happening. See

https://github.com/macports/macports-base/blob/master/portmgr/dmg/postflight.in#L281

that is supposed to set DISPLAY to :0 only if on Tiger and if DISPLAY is not already set. The problem is the check for 'Tiger or less' is broken for macOS 11, as it just checks the minor version < 4...

A fix is needed in base for this.

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

comment:34 Changed 3 months ago by collamaf

Dear All thanks for the wide support! So what should I do at the end of the day? can I comment that line in .zprofile? Or should I wait for an update of macports/that port? thanks!

comment:35 Changed 3 months ago by cjones051073 (Chris Jones)

remove the line yourself. the pull request above fixes base so, once deployed new installs using the fix will not have it added, but it will not address users that currently have it.

comment:36 in reply to:  35 Changed 3 months ago by collamaf

Replying to cjones051073:

remove the line yourself. the pull request above fixes base so, once deployed new installs using the fix will not have it added, but it will not address users that currently have it.

It works. Thank you very much for the help!

comment:37 Changed 3 months ago by cjones051073 (Chris Jones)

No problem, glad to help.

This ticket should remain open for reference for others, at least until the above fix is deployed in a release.

comment:38 Changed 3 months ago by ryandesign (Ryan Schmidt)

Component: portsbase
Keywords: bigsur added
Port: xinit removed

comment:39 Changed 3 months ago by jmroot (Joshua Root)

Summary: xorg not setting DISPLAY variable on Big Surinstaller postflight incorrectly sets DISPLAY variable on Big Sur

comment:40 Changed 3 months ago by MaddTheSane (C.W. Betts)

Cc: MaddTheSane added

comment:41 Changed 2 months ago by ryandesign (Ryan Schmidt)

Cc: rsmacleod added

Has duplicate #61950.

Note: See TracTickets for help on using tickets.