You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A language server's environment customizers run twice for each start #1892
Since #1693, a language server's or debug adapter's environment customizers (CommandLineEnvCustomizer) run twice for each start.
CommandUtils.getEffectiveEnvironment() runs the registered customizers to look up the command in the directory's PATH, on a map that is then thrown away, and the platform runs them again when it starts the process. Only the second run reaches the process, so the result is right; but a customizer that computes the environment by running an external tool, as a version manager's does, pays for it twice for every start.
Found in the review of #1693 (thread); not a blocker there.
A possible direction: compute the effective environment once per start and use it both for the lookup and for the process, or let the lookup use the customized environment that the start computes.
The second run turns out to be cheap for mise: the mise plugin caches the result of mise env for each working directory and clears it when the configuration changes (MiseCommandCache), so the run for the lookup and the run for the start compute it once. The cost only matters for a customizer that computes the environment again on each call.
A fix would also have to override how GeneralCommandLine starts its process, to look up the executable in the environment that the start customizes, and it could only do that for the command lines that LSP4IJ creates: a plugin's own command line would still get both runs. That's more risk than the gain is worth for now, so this stays open at low priority, until a customizer that doesn't cache makes the start of a language server slow.
Activity
lagergren commentedon Nov 7, 2026
#1893 adds the same lookup in two more places, so they run the customizers twice too:
OSProcessStreamConnectionProvider.start(), for a language server that a plugin starts with its ownGeneralCommandLine;ExecTask, for an installer's exec command.A fix should cover those as well. CodeRabbit raised both on #1893: ExecTask, OSProcessStreamConnectionProvider.
lagergren commentedon Nov 7, 2026
The second run turns out to be cheap for mise: the mise plugin caches the result of
mise envfor each working directory and clears it when the configuration changes (MiseCommandCache), so the run for the lookup and the run for the start compute it once. The cost only matters for a customizer that computes the environment again on each call.A fix would also have to override how
GeneralCommandLinestarts its process, to look up the executable in the environment that the start customizes, and it could only do that for the command lines that LSP4IJ creates: a plugin's own command line would still get both runs. That's more risk than the gain is worth for now, so this stays open at low priority, until a customizer that doesn't cache makes the start of a language server slow.fix: run a command's environment customizers once, and look it up wit…