Skip to content

Instances of a language server share a configured working directory, and with it one directory environment #1889

Closed

Description

@lagergren

With several instances of one language server per project (#1701, #1853), each instance that has no configured working directory runs in its root, so with directory environments (#1660, #1693) it gets the environment of its root, such as the node of a module's mise.toml. A configured working directory applies to every instance instead (testAConfiguredWorkingDirectoryAppliesToAnInstance in #1853), so all instances then share the environment of that one directory, and the per-root environments are lost.

Possible direction

Decide whether an instance should get the environment of its root even with a configured working directory, for instance by resolving a relative working directory against the instance root, or by a macro for the instance root that the working directory can use. Once #1853 and #1693 are in, it is the setting that decides whether a module's tools reach its instance.

Activity

  1. lagergren commented on Nov 10, 2026

    @lagergren
    CollaboratorAuthor

    #1929 settles this with a third way: ${instanceRoot}, for the command and the working directory of a user-defined language server.

    • With serverInstances, it is the root of each instance. ${instanceRoot}/server runs each instance in a directory of its own root, with the environment of that directory, such as its module's mise.toml.
    • Without them, it is the project's directory, as $PROJECT_DIR$, so the same configuration works with and without instances.

    Why this rather than the two directions above:

    • Keeping the current behavior and documenting it leaves no way to have both a working directory of one's choice and the environment of each root: for the environments, the working directory has to stay empty.
    • Resolving a relative working directory against the root of each instance changes what an existing setting means. Today a relative working directory is passed to the process as it is, which resolves it against the IDE's working directory. It would also cover the working directory only, not the command, and it would need another rule for a language server without instances.
    • ${instanceRoot} is an addition. A configuration without it works exactly as before: with the definition of main, only the tests that use it fail, and the tests of the defaults pass unchanged. Each setting chooses between one directory for all instances and one per root. It works in the command too, for instance for each module's own interpreter, as in "${instanceRoot}/.venv/bin/python" -m pylsp. And it follows LSP4IJ's existing ${port} placeholder.

    #1853 and #1693 are both new in 0.30.0, so the placeholder ships with them, before any configuration depends on all instances sharing one working directory. The name is open, if another one reads better. I avoided ${workspaceFolder}, which the launch configurations of debug adapters use for the working directory.

  2. added
    enhancement
    on Nov 10, 2026
  3. moved this to In Progress in Java Toolingon Nov 10, 2026
  4. added this to the 0.30.0 milestone on Nov 10, 2026
  5. moved this from In Progress to Done in Java Toolingon Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions