Skip to content

A language server's environment customizers run twice for each start #1892

Closed

Description

@lagergren

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.

Activity

  1. lagergren commented on Nov 7, 2026

    @lagergren
    CollaboratorAuthor

    #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 own GeneralCommandLine;
    • ExecTask, for an installer's exec command.

    A fix should cover those as well. CodeRabbit raised both on #1893: ExecTask, OSProcessStreamConnectionProvider.

  2. lagergren commented on Nov 7, 2026

    @lagergren
    CollaboratorAuthor

    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.

  3. added this to the 0.30.0 milestone on Nov 10, 2026
  4. added
    bug
    on Nov 10, 2026
  5. moved this to In Progress in Java Toolingon Nov 10, 2026
  6. moved this from In Progress to Done in Java Toolingon Nov 10, 2026
  7. added a commit that references this issue on Nov 11, 2026
    ff5e28d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions