Skip to content

Commit 0717bd0

Browse files
authored
Avoid adding BundledModulePath to PSModulePath repeatedly (#1641)
1 parent 96a8207 commit 0717bd0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,13 @@ private void UpdatePSModulePath()
269269
}
270270

271271
string psModulePath = Environment.GetEnvironmentVariable("PSModulePath").TrimEnd(Path.PathSeparator);
272+
if ($"{psModulePath}{Path.PathSeparator}".Contains($"{_hostConfig.BundledModulePath}{Path.PathSeparator}"))
273+
{
274+
_logger.Log(PsesLogLevel.Diagnostic, "BundledModulePath already set, skipping");
275+
return;
276+
}
272277
psModulePath = $"{psModulePath}{Path.PathSeparator}{_hostConfig.BundledModulePath}";
273278
Environment.SetEnvironmentVariable("PSModulePath", psModulePath);
274-
275279
_logger.Log(PsesLogLevel.Verbose, $"Updated PSModulePath to: '{psModulePath}'");
276280
}
277281

0 commit comments

Comments
 (0)