How can I execute UE4Editor on the command line as a different user than what is logged in?

This is on a Mac.

What I’m trying to do, is setup to automate our builds. To test the configuration, I’m running the UE4Editor app on the command line as the user.

/Users/Shared/UnrealEngine/4.2/Engine/Binaries/Mac/UE4Editor.app/Contents/MacOS/UE4Editor "/Users/Shared//Home/workspace/Game (AdHoc)/mainline/Game/Game.uproject" -run=Cook -MapIniSection=AllMaps -TargetPlatform=IOS -buildmachine -Unversioned -fileopenlog -abslog="/tmp/cook.txt" -stdout -FORCELOGFLUSH -CrashForUAT -unattended -AllowStdOutLogVerbosity

It fails with the following error:

_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.

The exact same command above works when run as the normal, logged in user. It appears as though UE4Editor needs to run as the logged in user in order to access the graphics card or display? Is there a command line option or something we can do to work around this problem?

Thanks.

Hi

I encounter the same problem with UE 4.5.
We currently set up CI for Windows and Mac. For windows everything is working fine.
On Mac we have problems.

I use this Bash call to start build, cook, and package process.
Build/BatchFiles/RunUAT.sh BuildCookRun -project=“$WORKSPACE/MyProject.uproject” -noP4 -IOS -clientconfig=$CONFIG -cook -maps=AllMaps -NoCompile -stage -pak -archive -archivedirectory=$WORKSPACE/SecretAge -Build

Engine is build from github source.

When I run this in the bash as the user it works fine. But if I run it in a JOB then I receive the same error:
CommandUtils.Run: Run: /private/var/lib//unrealengine/Engine/Binaries/Mac/UE4Editor.app/Contents/MacOS/UE4Editor /var/lib//workspace/MyProject/MyProject.uproject -run=Cook -MapIniSection=AllMaps -CookCultures=en -TargetPlatform=IOS -buildmachine -Unversioned -fileopenlog -abslog=“/var/lib//Library/Logs/Unreal Engine/LocalBuildLogs/Cook.9.txt” -stdout -FORCELOGFLUSH -CrashForUAT -unattended -AllowStdOutLogVerbosity
UE4Editor: _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
Build was aborted

This call is invoked after compiling it successfully. It seems that he wants to start the Unreal Editor which seems to be not allowed within a job.

Any advises on this?

thanks
ciao

As UE4Editor is a regular, ‘proper’ Mac application and even in unattended mode we have to make AppKit calls it will require access to the WindowServer. This is the normal function of OS X and it is not something that can be easily changed (or possibly changed at all depending on what is actually causing the dependency) in UE4Editor. As such the UE4Editor needs to be run with an account logged in and under a user with sufficient privileges to access the WindowServer. Apparently whatever user is using to launch the editor has insufficient privileges and hence it doesn’t work.