{"record":{"id":"145383846fc06560","repo":"ppy/osu","slug":"cannot-use-this-argument-in-a-non-debug-build","errorCode":null,"errorMessage":"Cannot use this argument in a non-debug build.","messagePattern":"Cannot use this argument in a non-debug build\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"osu.Desktop/Program.cs","lineNumber":95,"sourceCode":"            string gameName = base_game_name;\r\n            bool tournamentClient = false;\r\n\r\n            foreach (string arg in args)\r\n            {\r\n                string[] split = arg.Split('=');\r\n\r\n                string key = split[0];\r\n                string val = split.Length > 1 ? split[1] : string.Empty;\r\n\r\n                switch (key)\r\n                {\r\n                    case \"--tournament\":\r\n                        tournamentClient = true;\r\n                        break;\r\n\r\n                    case \"--debug-client-id\":\r\n                        if (!DebugUtils.IsDebugBuild)\r\n                            throw new InvalidOperationException(\"Cannot use this argument in a non-debug build.\");\r\n\r\n                        if (!int.TryParse(val, out int clientID))\r\n                            throw new ArgumentException(\"Provided client ID must be an integer.\");\r\n\r\n                        gameName = $\"{base_game_name}-{clientID}\";\r\n                        break;\r\n                }\r\n            }\r\n\r\n            var hostOptions = new HostOptions\r\n            {\r\n                IPCPipeName = !tournamentClient ? OsuGame.IPC_PIPE_NAME : null,\r\n                FriendlyGameName = OsuGameBase.GAME_NAME,\r\n            };\r\n\r\n            using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, hostOptions))\r\n            {\r\n                if (!host.IsPrimaryInstance)\r","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/ppy/osu/blob/d9c73e12adff2feaae4a3e158d36fe5883faf6ca/osu.Desktop/Program.cs#L77-L113","documentation":"The osu! desktop launcher exposes a --debug-client-id CLI flag used to assign a unique game-name suffix when running multiple client instances for debugging. This flag is gated behind DebugUtils.IsDebugBuild, which is only true in Debug-compiled builds. Passing the flag in a Release or non-debug build is rejected because the multi-instance debug feature is compiled out.","triggerScenarios":"Passing --debug-client-id <value> on the command line when the osu.Desktop binary was compiled with DebugUtils.IsDebugBuild == false (Release/ReleaseDebug configuration). The switch-case for --debug-client-id checks the conditional and throws InvalidOperationException immediately.","commonSituations":"Running a published or release build of osu! while a launch script, shortcut, or IDE profile still includes the --debug-client-id flag. Upgrading from a debug build to a release build without cleaning up launch arguments.","solutions":["Remove the --debug-client-id flag from your launch arguments when running a release build.","Rebuild osu.Desktop in Debug configuration (e.g., dotnet build -c Debug) if you need multi-instance debug support.","Conditionally include the flag only in a debug-specific launch profile or script that checks the build configuration."],"exampleFix":"// before\n// launch args: osu!.exe --debug-client-id 2  (on a release build)\n\n// after\n// launch args: osu!.exe\n// or rebuild in Debug: dotnet build -c Debug osu.Desktop","handlingStrategy":"validation","validationCode":"// Before passing --debug-client-id, verify the build supports it\n#if DEBUG\n    args = args.Append(\"--debug-client-id\").Append(clientId.ToString()).ToArray();\n#endif\n// Or check at runtime before launching:\nbool isDebugBuild = System.Diagnostics.Debugger.IsAttached || DebugUtils.IsDebugBuild;\nif (!isDebugBuild && args.Contains(\"--debug-client-id\"))\n    throw new InvalidOperationException(\"--debug-client-id requires a debug build.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep debug-only CLI flags in debug-only launch profiles or #if DEBUG blocks.","Document which CLI flags are debug-gated so release builds don't carry stale arguments.","Use a centralized argument parser that strips debug flags in release builds instead of throwing."],"tags":["configuration","command-line","debug-build","osu-desktop"],"backgroundTag":null,"analyzedSha":"d9c73e12adff2feaae4a3e158d36fe5883faf6ca","analyzedAt":"2026-08-13T14:12:54.015Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}