{"record":{"id":"b0d283715534395a","repo":"Unity-Technologies/UnityCsReference","slug":"getinstallationforpath-does-not-allow-null-editor","errorCode":null,"errorMessage":"GetInstallationForPath: Does not allow null editorPath","messagePattern":"GetInstallationForPath: Does not allow null editorPath","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/CodeEditor/CodeEditor.cs","lineNumber":115,"sourceCode":"            if (string.IsNullOrEmpty(assetPath))\n            {\n                return false;\n            }\n\n            var assetFilePath = Path.GetFullPath(assetPath);\n            var didOpenProject = Editor.CurrentCodeEditor.OpenProject(assetFilePath, line, column);\n            if (didOpenProject)\n            {\n                CodeEditorAnalytics.SendCodeEditorUsage(CodeEditor.Editor.CurrentCodeEditor);\n            }\n            return didOpenProject;\n        }\n\n        public Installation GetInstallationForPath(string editorPath)\n        {\n            if (editorPath == null)\n            {\n                throw new ArgumentException(\"GetInstallationForPath: Does not allow null editorPath\");\n            }\n\n            Installation installation;\n            if (editorPath == CodeEditor.SystemDefaultPath)\n            {\n                m_DefaultEditor.TryGetInstallationForPath(editorPath, out installation);\n                return installation;\n            }\n\n            foreach (var codeEditor in m_ExternalCodeEditors)\n            {\n                if (codeEditor.TryGetInstallationForPath(editorPath, out installation))\n                {\n                    return installation;\n                }\n            }\n            m_DefaultEditor.TryGetInstallationForPath(editorPath, out installation);\n            return installation;","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/CodeEditor/CodeEditor.cs#L97-L133","documentation":"ArgumentException thrown by CodeEditor.GetInstallationForPath when editorPath is null. The method must look up the IExternalCodeEditor installation for a path (including the SystemDefaultPath special case), so a null path is rejected up front before any editor iteration.","triggerScenarios":"Calling CodeEditor.GetInstallationForPath(null). Common when the editor path is read from EditorPrefs/project settings that are unset, or passed through from a caller that did not validate a user-selected script editor path.","commonSituations":"First-run scenarios where the external script editor preference ('kScriptsDefaultApp') has not been set; tooling that resolves the editor path from an environment variable or detection routine that can return null.","solutions":["Validate editorPath is non-null (and ideally non-empty/file-present) before calling GetInstallationForPath.","Fall back to CodeEditor.SystemDefaultPath when the detected path is null.","Ensure EditorPrefs for the script editor are set (Editor.SetCodeEditor) before querying installations."],"exampleFix":"// before\nvar install = CodeEditor.GetInstallationForPath(detectedPath);\n\n// after\nvar path = detectedPath ?? CodeEditor.SystemDefaultPath;\nvar install = CodeEditor.GetInstallationForPath(path);","handlingStrategy":"validation","validationCode":"if (editorPath == null) editorPath = CodeEditor.SystemDefaultPath;\nvar install = CodeEditor.GetInstallationForPath(editorPath);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Null-check editor paths before lookup.","Fall back to SystemDefaultPath when unset.","Set the script-editor preference before querying installations."],"tags":["unity-editor","code-editor","argument-validation","nullable"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}