{"record":{"id":"4c68c3ab88a601e4","repo":"JosefNemec/Playnite","slug":"emulator-executable-not-found-regular-expression","errorCode":null,"errorMessage":"Emulator executable not found.\n\nRegular expression lookup: {profileDef.StartupExecutable}","messagePattern":"Emulator executable not found\\.\n\nRegular expression lookup: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"source/Playnite/Controllers/GenericGameController.cs","lineNumber":187,"sourceCode":"                        $\"{emulator.Name} runtime for {Game.Name}\",\r\n                        Emulation.GetStartupScriptPath(def),\r\n                        emulator.InstallDir,\r\n                        new Dictionary<string, object>\r\n                        {\r\n                            { \"Emulator\", emulator.GetClone() },\r\n                            { \"EmulatorProfile\", profileDef.GetClone() },\r\n                            { \"RomPath\", romPath }\r\n                        },\r\n                        asyncExec);\r\n                }\r\n                else\r\n                {\r\n                    builtIn = builtIn.GetClone();\r\n                    startupDir = emulator.InstallDir;\r\n                    startupPath = Emulation.GetExecutable(emulator.InstallDir, profileDef, true);\r\n                    if (startupPath.IsNullOrEmpty())\r\n                    {\r\n                        throw new FileNotFoundException(ResourceProvider.GetString(LOC.ErrorEmulatorExecutableNotFound) +\r\n                            $\"\\n\\nRegular expression lookup: {profileDef.StartupExecutable}\");\r\n                    }\r\n\r\n                    if (action.OverrideDefaultArgs)\r\n                    {\r\n                        startupArgs = Game.ExpandVariables(action.Arguments, false, emulator.InstallDir, romPath);\r\n                    }\r\n                    else\r\n                    {\r\n                        if (builtIn.OverrideDefaultArgs)\r\n                        {\r\n                            startupArgs = Game.ExpandVariables(builtIn.CustomArguments, false, emulator.InstallDir, romPath);\r\n                        }\r\n                        else\r\n                        {\r\n                            startupArgs = Game.ExpandVariables(profileDef.StartupArguments, false, emulator.InstallDir, romPath);\r\n                        }\r\n\r","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Controllers/GenericGameController.cs#L169-L205","documentation":"Thrown as FileNotFoundException when a built-in emulator profile's StartupExecutable regex pattern fails to match any file inside the emulator's InstallDir. The controller calls Emulation.GetExecutable() which recursively enumerates all files under InstallDir and applies the profile's StartupExecutable regex; if no file matches, it returns null/empty and this error fires. The message includes the offending regex so the developer can see exactly what pattern failed.","triggerScenarios":"Calling Start on a game whose play action is a built-in emulator profile (BuiltInEmulatorProfile), where the emulator InstallDir contains files but none match the profileDef.StartupExecutable regex pattern. Occurs in GenericGameController when profileDef.ScriptStartup is false and the non-script code path executes (line 184).","commonSituations":"The emulator was updated and its executable was renamed (e.g., retroarch.exe moved or versioned). The emulator InstallDir is wrong (points to a launcher/updater folder, not the real install). The built-in emulator definition's StartupExecutable regex is stale after an emulator update. A portable emulator was installed to a different subdirectory than the definition expects.","solutions":["Verify the emulator InstallDir is correct: open the emulator settings in Playnite and confirm the installation path points to the folder containing the real executable.","Check the regex pattern from the error message against the actual files in InstallDir: list files recursively and test if any match the StartupExecutable regex.","Update Playnite or the emulator definitions pack: a stale definition with an outdated regex is the most common cause after an emulator version bump.","Switch the game's emulator profile to a custom profile where you specify the exact executable path instead of relying on the built-in regex.","Reinstall or re-detect the emulator so its InstallDir reflects the current file layout."],"exampleFix":"// before — relying on built-in regex match that no longer works\nstartupPath = Emulation.GetExecutable(emulator.InstallDir, profileDef, true);\nif (startupPath.IsNullOrEmpty())\n{\n    throw new FileNotFoundException(ResourceProvider.GetString(LOC.ErrorEmulatorExecutableNotFound) +\n        $\"\\n\\nRegular expression lookup: {profileDef.StartupExecutable}\");\n}\n\n// after — user switches to a custom emulator profile with an explicit path\n// Configure the game to use a CustomEmulatorProfile with ExecutablePath set to the verified .exe location.","handlingStrategy":"validation","validationCode":"string exe = Emulation.GetExecutable(emulator.InstallDir, profileDef, false);\nif (exe.IsNullOrEmpty())\n{\n    logger.Warn($\"No executable matching '{profileDef.StartupExecutable}' in {emulator.InstallDir}.\");\n    return; // or prompt user to reconfigure\n}","typeGuard":"static bool IsValidEmulatorExecutable(string installDir, EmulatorDefinitionProfile profile)\n{\n    return Directory.Exists(installDir) &&\n           !Emulation.GetExecutable(installDir, profile, false).IsNullOrEmpty();\n}","tryCatchPattern":"try\n{\n    controller.Start(action, true, startingArgs);\n}\ncatch (FileNotFoundException ex) when (ex.Message.Contains(\"Regular expression lookup\"))\n{\n    logger.Error($\"Emulator executable regex failed: {ex.Message}\");\n    Dialogs.ShowMessage(\"The emulator executable was not found. Please check the emulator installation path and profile settings.\");\n}","preventionTips":["After configuring or updating an emulator, test-launch one game to verify the StartupExecutable regex matches.","Keep emulator definitions updated alongside Playnite updates.","For emulators that rename executables across versions, use custom profiles with explicit paths instead of built-in regex."],"tags":["emulator","file-not-found","regex","executable-path","play-action"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}