{"record":{"id":"f1b99041d243ba77","repo":"LykosAI/StabilityMatrix","slug":"venv-python-not-found-uvvenvrunner","errorCode":null,"errorMessage":"Venv python not found","messagePattern":"Venv python not found","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Python/UvVenvRunner.cs","lineNumber":550,"sourceCode":"        );\n        await process.WaitForExitAsync().ConfigureAwait(false);\n\n        return new ProcessResult { ExitCode = process.ExitCode, StandardOutput = output.ToString() };\n    }\n\n    [MemberNotNull(nameof(Process))]\n    public void RunDetached(\n        ProcessArgs args,\n        Action<ProcessOutput>? outputDataReceived,\n        Action<int>? onExit = null,\n        bool unbuffered = true\n    )\n    {\n        var arguments = args.ToString();\n\n        if (!PythonPath.Exists)\n        {\n            throw new FileNotFoundException(\"Venv python not found\", PythonPath);\n        }\n        SetPyvenvCfg(BaseInstall.RootPath);\n\n        Logger.Info(\n            \"Launching venv process [{PythonPath}] \"\n                + \"in working directory [{WorkingDirectory}] with args {Arguments}\",\n            PythonPath,\n            WorkingDirectory?.ToString(),\n            arguments\n        );\n\n        var filteredOutput =\n            outputDataReceived == null\n                ? null\n                : new Action<ProcessOutput>(s =>\n                {\n                    if (SuppressOutput.Any(s.Text.Contains))\n                    {","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Python/UvVenvRunner.cs#L532-L568","documentation":"UvVenvRunner.RunDetached throws FileNotFoundException(\"Venv python not found\", PythonPath) when the venv's Python executable (PythonPath) does not exist just before launching a detached process. It guards against spawning a process with a missing interpreter; CustomInstall and other run helpers inherit this failure through RunDetached.","triggerScenarios":"Calling CustomInstall/RunDetached (or PipInstall/PipUninstall via RunUvDetached flows that still check PythonPath) when the venv directory was deleted, the venv was created for a different platform/layout, or BaseInstall points to a nonexistent Python install.","commonSituations":"User deleted or moved the shared venv folder; an upgrade wiped the venv; the venv was created with `uv venv --python-version` pointing at an interpreter that failed to download; wrong working directory assumptions after relocation.","solutions":["Recreate the venv (UvVenvRunner.SetupUvVenv / re-run setup) so PythonPath exists.","Verify File.Exists(PythonPath) (or PythonPath.Exists) before calling and re-setup if missing.","Check BaseInstall.RootPath points at the correct, intact Python installation.","If the install was moved, re-point the runner's paths rather than launching against the stale location."],"exampleFix":"// before: launching without checking the venv exists\nawait runner.CustomInstall(args);\n// after: ensure venv first\nif (!File.Exists(runner.PythonPath)) {\n    await runner.SetupUvVenv(); // recreate venv and interpreter\n}\nawait runner.CustomInstall(args);","handlingStrategy":"validation","validationCode":"if (!File.Exists(runner.PythonPath)) {\n    await runner.SetupUvVenv(); // recreate venv before running commands\n}","typeGuard":"static bool VenvExists(UvVenvRunner r) => File.Exists(r.PythonPath);","tryCatchPattern":"try { await runner.CustomInstall(args); }\ncatch (FileNotFoundException ex) { Logger.Error($\"venv missing: {ex.FileName}\"); await RecreateVenvAsync(); }","preventionTips":["Always ensure the venv is set up after installs, upgrades, or folder moves.","Never assume the venv survives app updates or user cleanups.","Centralize venv existence checks in one helper before any run call."],"tags":["python","venv","file-not-found","process"],"backgroundTag":"file-not-found","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}