Skip to content

A user-defined language server without a working directory doesn't get the environment of the project's directory #1886

Done

Description

@lagergren

A user-defined language server has no working directory unless the user sets one. Its process then starts in the IDE's working directory, and with directory environments (#1660, #1693) it gets no directory's environment, and its command is looked up in the IDE's PATH. So a project whose mise.toml or .envrc selects the tools, such as its version of node, doesn't get them for its language servers unless each server's working directory is set.

How it happens

UserDefinedLanguageServerDefinition.workingDir is null unless it is configured, and createConnectionProvider passes it as it is. The platform customizes the environment of a process for its working directory; without one, a customizer such as mise's has no directory to take the environment from.

Possible direction

Default the working directory to the project's directory ($PROJECT_DIR$), for new definitions or whenever it is empty. A server whose command or arguments rely on the IDE's working directory today, such as a relative path, would then resolve it against the project's directory, so this needs a decision on compatibility, or a default only for new definitions. Until then, #1693 documents that the working directory has to be set.

Activity

  1. lagergren commented on Nov 7, 2026

    @lagergren
    CollaboratorAuthor

    @angelozerr before I put up a PR for this, which default working directory do you want for a user-defined language server?

    1. None, as today. feat: support directory environment variables #1693 documents that the working directory has to be set for the directory's environment to apply.
    2. $PROJECT_DIR$ for new definitions only, from the dialog and the templates. Existing definitions keep what they have.
    3. The project's directory whenever none is set, for existing definitions too. A server whose command relies on the IDE's working directory, such as a relative path, would resolve it against the project's directory instead. The IDE's working directory is rarely meaningful (/ on macOS, the home or bin directory elsewhere), so I doubt anything relies on it, but it is a change for existing users.

    With #1853, an instance without a working directory runs in its root, so with 3, the default would have to stay the instance root for an instance and be the project's directory otherwise.

    I'd go with 3, with that exception for instances, or with 2 if you'd rather not change existing definitions.

  2. lagergren commented on Nov 9, 2026

    @lagergren
    CollaboratorAuthor

    @angelozerr, a ping on this before 0.30.0: most user-defined language servers have no working directory, so without a default they don't get the directory environment of #1693, which is new in this release. Which of the three would you like? Once you pick one, I can put up the PR the same day. #1885 asks the same question for a DAP configuration created from a file.

  3. added
    bug
    on Nov 21, 2026
  4. lagergren commented on Nov 25, 2026

    @lagergren
    CollaboratorAuthor

    Going with option 3: a server without a working directory now starts in the project's directory (an instance in its root), and gets its environment. The empty field shows "Project directory". See #2233.

  5. added a commit that references this issue on Nov 25, 2026
    e7f4339
  6. added this to the 0.30.2 milestone on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buguser-defined LS

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions