Inconsistent batchmode errors on OS X (CLI licensing bug?)

Hi friends, we’re getting inconsistent outcomes when building on OS X Sonoma (14.7)

Summary:

I can build for OSX and iOS from the OSX 2022.3.x Editor GUI and they run as expected. When I build from a CLI script that worked last week, I get an unknown error (licensing?). Only possible related workstation change during that period was update Xcode from 15 to 16.2.

I’ve tried restarting, upgrading to 2022.3.54, cleaning the project different ways, and logging out of Unity Hub multiple times – no change and I really need some love at this point.

CLI invocation (parsed in .cs below):

".../2022.3.54f1/Unity.app/Contents/MacOS/Unity"  -quit -batchmode  -nographics -buildTarget StandaloneOSX -projectPath "..." -executeMethod Amp.Build.BuildPlayer -outputPath "..." -build-version "0.8.6" -build-number "2024121723" -build-tags   "None" -logFile ".../build.StandaloneOSX.log"

The build report says only 1 error and so I presume there is a licensing problem since the areas with the string error are tied to licensing:

 % grep "\[Licensing::" .../build.StandaloneOSX.log
[Licensing::Module] Trying to connect to existing licensing client channel...
[Licensing::IpcConnector] Successfully connected to: "LicenseClient-aomeara" at "2024-12-18T15:39:27.763198Z"
[Licensing::Client] Code 10 while verifying Licensing Client signature (process Id: 1316, path: "/Applications/Unity Hub.app/Contents/Frameworks/UnityLicensingClient_V1.app/Contents/MacOS/Unity.Licensing.Client")
[Licensing::Module] LicensingClient has failed validation; ignoring
[Licensing::Client] Error: HandshakeResponse reported an error:
[Licensing::Module] Error: Failed to handshake to channel: "LicenseClient-aomeara"
[Licensing::IpcConnector] LicenseClient-aomeara channel disconnected successfully.
[Licensing::IpcConnector] Channel LicenseClient-aomeara-2022.3.54 doesn't exist
[Licensing::Module] Successfully launched the LicensingClient (PId: 8614)
[Licensing::IpcConnector] Successfully connected to: "LicenseClient-aomeara-2022.3.54" at "2024-12-18T15:39:28.387404Z"
[Licensing::Client] Code 1 while verifying Licensing Client signature (process Id: 8614, path: "/Users/aomeara/Applications/2022.3.54f1/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client")
[Licensing::Module] LicensingClient has failed validation; ignoring
[Licensing::Client] Handshaking with LicensingClient:
[Licensing::Module] Successfully connected to LicensingClient on channel: "LicenseClient-aomeara-2022.3.54" (connect: 0.41s, validation: 0.03s, handshake: 0.01s)
[Licensing::IpcConnector] Successfully connected to: "LicenseClient-aomeara-2022.3.54-notifications" at "2024-12-18T15:39:28.425211Z"
[Licensing::Module] Connected to LicensingClient (PId: 8614, launch time: 0.00, total connection time: 0.44s)
[Licensing::Module] Error: Access token is unavailable; failed to update
[Licensing::Client] Successfully updated license
[Licensing::Client] Successfully resolved entitlement details
[Licensing::Module] Serial number assigned to: "F4-MNT4-KBWQ-UGVE-EPHH-XXXX"
[Licensing::Module] Serial number assigned to: "1374563359158-UnityPersXXXX"
[Licensing::Client] Successfully resolved entitlement details
...
[Licensing::IpcConnector] LicenseClient-aomeara-2022.3.54-notifications channel disconnected successfully.
[Licensing::IpcConnector] LicenseClient-aomeara-2022.3.54 channel disconnected successfully.

If I add -username '...' -password '...' to the invocation it still errors similarly with these lines different instead:

...
[Licensing::Module] Successfully launched the LicensingClient (PId: 8310)
[Licensing::IpcConnector] Successfully connected to: "LicenseClient-aomeara-2022.3.54" at "2024-12-18T15:26:54.581894Z"
[Licensing::Client] Code 1 while verifying Licensing Client signature (process Id: 8310, path: "/Users/aomeara/Applications/2022.3.54f1/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client")
[Licensing::Module] LicensingClient has failed validation; ignoring
[Licensing::Client] Handshaking with LicensingClient:
[Licensing::Module] Successfully connected to LicensingClient on channel: "LicenseClient-aomeara-2022.3.54" (connect: 0.40s, validation: 0.03s, handshake: 0.01s)
[Licensing::IpcConnector] Successfully connected to: "LicenseClient-aomeara-2022.3.54-notifications" at "2024-12-18T15:26:54.619491Z"
[Licensing::Module] Connected to LicensingClient (PId: 8310, launch time: 0.00, total connection time: 0.43s)
[Licensing::Client] Successfully updated the access token
[Licensing::Module] Successfully updated the access token 32GTEq2QN2...
...

Meanwhile, I check the Unity.License.Client.log and I see this:

 grep -i "warn" /Users/aomeara/Library/Logs/Unity/Unity.Licensing.Client.log  
2024-12-18 06:02:58.382 - [  5263] - [    13] - WARN  - [Unity.Licensing.Client.Services.Licensing.GenesisLicensingService] Failed to update license file. [Code: 401] Token not found in cache
2024-12-18 06:02:58.482 - [  5263] - [    15] - WARN  - [PackageService.HttpRequests] Handled response: [304 | Not Modified | ] from request: [GET | https://license.unity3d.com/licenses/v1/packages/acl | ]
2024-12-18 15:17:56.531 - [  7517] - [     8] - WARN  - [Unity.Licensing.Client.Services.Licensing.GenesisLicensingService] Failed to update license file. [Code: 401] Token not found in cache
2024-12-18 15:17:56.736 - [  7517] - [    13] - WARN  - [PackageService.HttpRequests] Handled response: [304 | Not Modified | ] from request: [GET | https://license.unity3d.com/licenses/v1/packages/acl | ]
2024-12-18 15:21:05.567 - [  7700] - [    16] - WARN  - [Unity.Licensing.Client.Services.Licensing.GenesisLicensingService] Failed to update license file. [Code: 401] Token not found in cache
2024-12-18 15:21:05.684 - [  7700] - [    13] - WARN  - [PackageService.HttpRequests] Handled response: [304 | Not Modified | ] from request: [GET | https://license.unity3d.com/licenses/v1/packages/acl | ]
2024-12-18 15:25:49.593 - [  7700] - [    17] - WARN  - [Unity.Licensing.Client.Services.Licensing.GenesisLicensingService] Failed to update license file. [Code: 401] Token not found in cache
2024-12-18 15:26:02.081 - [  8208] - [     6] - WARN  - [Unity.Licensing.Client.Services.Licensing.GenesisLicensingService] Failed to update license file. [Code: 401] Token not found in cache
2024-12-18 15:26:02.201 - [  8208] - [    13] - WARN  - [PackageService.HttpRequests] Handled response: [304 | Not Modified | ] from request: [GET | https://license.unity3d.com/licenses/v1/packages/acl | ]
2024-12-18 15:26:54.820 - [  8310] - [    20] - WARN  - [PackageService.HttpRequests] Handled response: [304 | Not Modified | ] from request: [GET | https://license.unity3d.com/licenses/v1/packages/acl | ]
2024-12-18 15:39:28.450 - [  8614] - [    11] - WARN  - [Unity.Licensing.Client.Services.Licensing.GenesisLicensingService] Failed to update license file. [Code: 401] Token not found in cache
2024-12-18 15:39:28.616 - [  8614] - [     8] - WARN  - [PackageService.HttpRequests] Handled response: [304 | Not Modified | ] from request: [GET | https://license.unity3d.com/licenses/v1/packages/acl | ]
aomeara@true ~ % 
aomeara@true ~ % 
aomeara@true ~ % grep -i "err" /Users/aomeara/Library/Logs/Unity/Unity.Licensing.Client.log  
2024-12-18 06:02:57.733 - [  1316] - [    42] - INFO  - [Unity.Licensing.Client.Communication.ApiPipeHandler#17] REQ-1 | Sending ApiErrorResponse for request HandshakeRequest from UnityEditor/2022.3.54f1 (Macintosh; U; Intel Mac OS X 14.7; en-US) (LocalIPC/1.16.1) [505]:  Unsupported protocol version '1.16.1'.
2024-12-18 06:02:59.542 - [  5263] - [    13] - ERROR - [Unity.Licensing.Client.Communication.Controllers.UpdateLicenseController] assigned update failed. Details: Token not found in cache
2024-12-18 15:17:55.856 - [  1316] - [    28] - INFO  - [Unity.Licensing.Client.Communication.ApiPipeHandler#18] REQ-1 | Sending ApiErrorResponse for request HandshakeRequest from UnityEditor/2022.3.54f1 (Macintosh; U; Intel Mac OS X 14.7; en-US) (LocalIPC/1.16.1) [505]:  Unsupported protocol version '1.16.1'.
2024-12-18 15:17:58.001 - [  7517] - [     8] - ERROR - [Unity.Licensing.Client.Communication.Controllers.UpdateLicenseController] assigned update failed. Details: Token not found in cache
2024-12-18 15:21:05.084 - [  1316] - [    23] - INFO  - [Unity.Licensing.Client.Communication.ApiPipeHandler#19] REQ-1 | Sending ApiErrorResponse for request HandshakeRequest from UnityEditor/2022.3.54f1 (Macintosh; U; Intel Mac OS X 14.7; en-US) (LocalIPC/1.16.1) [505]:  Unsupported protocol version '1.16.1'.
2024-12-18 15:21:06.611 - [  7700] - [    16] - ERROR - [Unity.Licensing.Client.Communication.Controllers.UpdateLicenseController] assigned update failed. Details: Token not found in cache
2024-12-18 15:25:49.558 - [  1316] - [    26] - INFO  - [Unity.Licensing.Client.Communication.ApiPipeHandler#20] REQ-1 | Sending ApiErrorResponse for request HandshakeRequest from UnityEditor/2022.3.54f1 (Macintosh; U; Intel Mac OS X 14.7; en-US) (LocalIPC/1.16.1) [505]:  Unsupported protocol version '1.16.1'.
2024-12-18 15:25:50.957 - [  7700] - [    17] - ERROR - [Unity.Licensing.Client.Communication.Controllers.UpdateLicenseController] assigned update failed. Details: Token not found in cache
2024-12-18 15:26:01.610 - [  1316] - [    26] - INFO  - [Unity.Licensing.Client.Communication.ApiPipeHandler#21] REQ-1 | Sending ApiErrorResponse for request HandshakeRequest from UnityEditor/2022.3.54f1 (Macintosh; U; Intel Mac OS X 14.7; en-US) (LocalIPC/1.16.1) [505]:  Unsupported protocol version '1.16.1'.
2024-12-18 15:26:03.151 - [  8208] - [     6] - ERROR - [Unity.Licensing.Client.Communication.Controllers.UpdateLicenseController] assigned update failed. Details: Token not found in cache
2024-12-18 15:26:54.183 - [  1316] - [    29] - INFO  - [Unity.Licensing.Client.Communication.ApiPipeHandler#22] REQ-1 | Sending ApiErrorResponse for request HandshakeRequest from UnityEditor/2022.3.54f1 (Macintosh; U; Intel Mac OS X 14.7; en-US) (LocalIPC/1.16.1) [505]:  Unsupported protocol version '1.16.1'.
2024-12-18 15:39:27.982 - [  1316] - [     6] - INFO  - [Unity.Licensing.Client.Communication.ApiPipeHandler#23] REQ-1 | Sending ApiErrorResponse for request HandshakeRequest from UnityEditor/2022.3.54f1 (Macintosh; U; Intel Mac OS X 14.7; en-US) (LocalIPC/1.16.1) [505]:  Unsupported protocol version '1.16.1'.
2024-12-18 15:39:29.662 - [  8614] - [    11] - ERROR - [Unity.Licensing.Client.Communication.Controllers.UpdateLicenseController] assigned update failed. Details: Token not found in cache

If I invoke with -noUPM, instead there are dozens of errors for each .asmdef in my project (so I can only assume UPM is required for builds):

...
Assets/Plugins/FMOD/src/EventHandler.cs(2,19): error CS0234: The type or namespace name 'EventSystems' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
Assets/Plugins/FMOD/src/EventHandler.cs(6,57): error CS0246: The type or namespace name 'IPointerEnterHandler' could not be found (are you missing a using directive or an assembly reference?)
Assets/Plugins/FMOD/src/EventHandler.cs(6,79): error CS0246: The type or namespace name 'IPointerExitHandler' could not be found (are you missing a using directive or an assembly reference?)
Assets/Plugins/FMOD/src/EventHandler.cs(6,100): error CS0246: The type or namespace name 'IPointerDownHandler' could not be found (are you missing a using directive or an assembly reference?)
...

And here’s the invoked build script:

namespace Amp {

    public static class Build {
        
        public static void                  BuildPlayer() {
        
            // SETUP JOB
            var args = Environment.GetCommandLineArgs();
            var job = new BuildJob();
            job.ParseArgs(args);

            // SET BACKEND
            PlayerSettings.SetScriptingBackend(job.PlayerOpts.targetGroup, job.Backend);

            // DO BUILD
            var buildReport = BuildPipeline.BuildPlayer(job.PlayerOpts);
            LogSummary(buildReport.summary);
            if (buildReport.summary.result != BuildResult.Succeeded) {
                EditorApplication.Exit(-37);
            }
            
            // FINALIZE
            job.FinalizeBundledAssets();
        }
    }

...

    public class BuildJob {
        static readonly string EOL = "\n";

        public string                       ProjectPath;
        public string                       BuildTags;
        public ScriptingImplementation      Backend;
        public Dictionary<string, string>   Args = new();
        public BuildPlayerOptions           PlayerOpts = new() {
            scenes  = new [] {
                "Assets/Scenes/app.unity",
            },
            //options = BuildOptions.DetailedBuildReport,  // crashes Unity 2022.3.53
        };
        
        public void                         ParseArgs(string[] args) {

            ...

            if (!this.Args.TryGetValue("projectPath", out this.ProjectPath)) {
                Console.WriteLine("Missing -projectPath");
                EditorApplication.Exit(110);
            }
            
            try {
                string build_target = this.Args["buildTarget"];
                this.PlayerOpts.target = (BuildTarget) Enum.Parse(typeof(BuildTarget), build_target);
                this.PlayerOpts.targetGroup = BuildPipeline.GetBuildTargetGroup(this.PlayerOpts.target);
            } catch (Exception ex) {
                ...
            }

            this.Args.TryGetValue("outputPath", out string output_path);
            if (string.IsNullOrEmpty(output_path)) {
                ...
            }
            
            this.Args.TryGetValue("build-version", out string build_version);
            if (string.IsNullOrEmpty(build_version) || build_version.Contains(".") == false) {
                ...
            }
            
            if (this.PlayerOpts.target == BuildTarget.Android) {
                try {
                    PlayerSettings.Android.keystoreName = this.Args["keystore"];
                } catch (Exception ex) {
                    ...
                }
        
            }
            
        
            
            {
                this.Args.TryGetValue("build-number", out string build_number);
                string versStr = $"{build_version}.{build_number}";
                
                PlayerSettings.bundleVersion = versStr;
        
                switch (this.PlayerOpts.target) {
                    case BuildTarget.StandaloneOSX:
                        PlayerSettings.macOS.buildNumber = build_number;
                        output_path += ".app";
                        break;
                    case BuildTarget.iOS:
                        PlayerSettings.iOS.buildNumber = build_number;
                        break;
                    case BuildTarget.VisionOS:
                        PlayerSettings.VisionOS.buildNumber = build_number;
                        PlayerSettings.visionOSBundleVersion = build_version;
                        break;
                    case BuildTarget.Android:
                        PlayerSettings.Android.bundleVersionCode = int.Parse(build_number);
                        break;
                }
                
                this.PlayerOpts.locationPathName = output_path;
            }
            
            
            {
                this.Args.TryGetValue("build-tags", out this.BuildTags);
                this.BuildTags = this.BuildTags.ToLower();
                this.Backend = ScriptingImplementation.Mono2x;
               
                if (this.HasTag("debug")) {
                    this.PlayerOpts.options |= 
                        BuildOptions.Development |
                        BuildOptions.AllowDebugging;
                } else if (this.HasTag("il2cpp")) {
                    this.Backend = ScriptingImplementation.IL2CPP;
                }
                
            }
            
        
        }
    }
}

I’m 20 year dev, recent Unity dev + fan, and looking forward to upgrading to Pro when ship this title and not be burning through time on this stuff. Thanks!

Drew

SOLVED –
The call PlayerSettings.SetScriptingBackend(...) was the issue – removing it addresses the erratic behavior. Happy to file bug report if someone at Unity engineering thinks this is worthwhile.