Unity-Technologies/UnityCsReference · error · ArgumentException
GetInstallationForPath: Does not allow null editorPath
Error message
GetInstallationForPath: Does not allow null editorPath
What it means
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.
Source
Thrown at Editor/Mono/CodeEditor/CodeEditor.cs:115
if (string.IsNullOrEmpty(assetPath))
{
return false;
}
var assetFilePath = Path.GetFullPath(assetPath);
var didOpenProject = Editor.CurrentCodeEditor.OpenProject(assetFilePath, line, column);
if (didOpenProject)
{
CodeEditorAnalytics.SendCodeEditorUsage(CodeEditor.Editor.CurrentCodeEditor);
}
return didOpenProject;
}
public Installation GetInstallationForPath(string editorPath)
{
if (editorPath == null)
{
throw new ArgumentException("GetInstallationForPath: Does not allow null editorPath");
}
Installation installation;
if (editorPath == CodeEditor.SystemDefaultPath)
{
m_DefaultEditor.TryGetInstallationForPath(editorPath, out installation);
return installation;
}
foreach (var codeEditor in m_ExternalCodeEditors)
{
if (codeEditor.TryGetInstallationForPath(editorPath, out installation))
{
return installation;
}
}
m_DefaultEditor.TryGetInstallationForPath(editorPath, out installation);
return installation;View on GitHub (pinned to 225b0fbdb5)
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.
Example fix
// before var install = CodeEditor.GetInstallationForPath(detectedPath); // after var path = detectedPath ?? CodeEditor.SystemDefaultPath; var install = CodeEditor.GetInstallationForPath(path);
Defensive patterns
Strategy: validation
Validate before calling
if (editorPath == null) editorPath = CodeEditor.SystemDefaultPath; var install = CodeEditor.GetInstallationForPath(editorPath);
Prevention
- Null-check editor paths before lookup.
- Fall back to SystemDefaultPath when unset.
- Set the script-editor preference before querying installations.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- GetCodeEditorForPath: Does not allow null editorPath
- SetCodeEditor: Does not allow null editorPath
- Unexpected resultBits Span length. The expected length of re
- Not a valid handle, has it been released already?
- No command with id {commandId} exists
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/b0d283715534395a.
Report an issue: GitHub.