Skip to content

Please support using directory environment variables in LSP and DAP #1660

Closed

Description

@PassingByThs
  1. Basic information.
    I am using mise to manage dev tools and env vars.
    For example, it is using [email protected] in folder /e/documents/temp/lsp4ij and but [email protected] in folder /e/documents/temp/lsp4ij/useEnv.
david@lywPc /e/documents/temp/lsp4ij
$ mise ls -c
Tool                            Version           Source                                   Requested  
go                              1.26.3 (symlink)  C:\Users\david\.config\mise\config.toml  1.26
java                            21 (symlink)      C:\Users\david\.config\mise\config.toml  21
node                            24.19.0           C:\Users\david\.config\mise\config.toml  24.19.0
npm:@colbymchenry/codegraph     1.5.0             C:\Users\david\.config\mise\config.toml  1.5.0
npm:@dbx-app/mcp-server         0.4.62            C:\Users\david\.config\mise\config.toml  0.4.62
npm:@deepseek-ai/dsh            0.1.0-rc.7        C:\Users\david\.config\mise\config.toml  0.1.0-rc.7
npm:@vue/language-server        2.2.8             C:\Users\david\.config\mise\config.toml  2.2.8
npm:bash-language-server        5.6.0             C:\Users\david\.config\mise\config.toml  5.6.0
npm:stylelint-lsp               2.0.1             C:\Users\david\.config\mise\config.toml  2.0.1
npm:typescript                  5.6.3             C:\Users\david\.config\mise\config.toml  5.6.3
npm:typescript-language-server  5.3.0             C:\Users\david\.config\mise\config.toml  5.3.0
python                          3 (symlink)       C:\Users\david\.config\mise\config.toml  3

david@lywPc /e/documents/temp/lsp4ij
$ node -v
v24.19.0

david@lywPc /e/documents/temp/lsp4ij
$ cd useEnv/

david@lywPc /e/documents/temp/lsp4ij/useEnv
$ mise ls -c
Tool                            Version           Source                                     Requested  
go                              1.26.3 (symlink)  C:\Users\david\.config\mise\config.toml    1.26
java                            21 (symlink)      C:\Users\david\.config\mise\config.toml    21
node                            16.20.2           E:\documents\temp\lsp4ij\useEnv\mise.toml  16.20.2
npm:@colbymchenry/codegraph     1.5.0             C:\Users\david\.config\mise\config.toml    1.5.0
npm:@dbx-app/mcp-server         0.4.62            C:\Users\david\.config\mise\config.toml    0.4.62
npm:@deepseek-ai/dsh            0.1.0-rc.7        C:\Users\david\.config\mise\config.toml    0.1.0-rc.7
npm:@vue/language-server        2.2.8             C:\Users\david\.config\mise\config.toml    2.2.8
npm:bash-language-server        5.6.0             C:\Users\david\.config\mise\config.toml    5.6.0
npm:stylelint-lsp               2.0.1             C:\Users\david\.config\mise\config.toml    2.0.1
npm:typescript                  5.6.3             C:\Users\david\.config\mise\config.toml    5.6.3
npm:typescript-language-server  5.3.0             C:\Users\david\.config\mise\config.toml    5.3.0
python                          3 (symlink)       C:\Users\david\.config\mise\config.toml    3

david@lywPc /e/documents/temp/lsp4ij/useEnv
$ node -v
v16.20.2

david@lywPc /e/documents/temp/lsp4ij/useEnv
$ ll
total 3.0K
-rw-r--r-- 1 david david  25 Sep  2 21:22 mise.toml
-rw-r--r-- 1 david david 250 Sep  2 21:26 package.json
-rw-r--r-- 1 david david  78 Sep  2 21:31 test.js

david@lywPc /e/documents/temp/lsp4ij/useEnv
$ 

/e/documents/temp/lsp4ij/useEnv/package.json

{
  "name": "useenv",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "nodeVersion": "node -v"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

/e/documents/temp/lsp4ij/useEnv/test.js

console.log("enter test.js");
console.log(`node version: ${process.version}`);
  1. Npm Run/Debug Configuration is using env vars ( [email protected] e.g.) under folder useEnv.
    Create Run/Debug Configuration useEnv as below and run it.
Image You can see it is using env vars ( [email protected] e.g.) under folder `useEnv`. Image
  1. But DAP is using [email protected], not the env vars under folder useEnv.
Image

Activity

  1. angelozerr commented on Sep 2, 2026

    @angelozerr
    Contributor
    Image
  2. PassingByThs commented on Sep 2, 2026

    @PassingByThs
    Author

    What I mean is to use the environment variables associated with the specific folder (which can be managed using mise), similar to how other run configurations in IntelliJ IDEA are set up, rather than manually configuring them separately.

  3. angelozerr commented on Oct 10, 2026

    @angelozerr
    Contributor

    @sohamsakhare76-ai are you interested to work on this issue?

  4. sohamsakhare76-ai commented on Oct 10, 2026

    @sohamsakhare76-ai
    Contributor

    Hi Angelo! We are together again...Yes, I'd be happy to work on this issue. I'll investigate how directory environment variables are currently handled in LSP and DAP configurations and explore a possible solution. Thanks for reaching out!

  5. sohamsakhare76-ai commented on Oct 10, 2026

    @sohamsakhare76-ai
    Contributor

    Hi Angelo! I've traced the LSP and DAP process-launching paths. Both currently configure system/user-defined environment variables and set the working directory separately.

    Before implementing the fix, could you clarify whether you expect us to reuse an IntelliJ Platform API for resolving directory-specific environments, or whether the solution should explicitly support tools such as mise? I'd like to keep the implementation consistent with LSP4IJ's architecture.

  6. PassingByThs commented on Oct 10, 2026

    @PassingByThs
    Author

    It doesn't necessarily require supporting specific tools like "mise," and in fact, there are many similar tools that does what mise do. I believe that simply supporting the use of environment variables bound to directories is sufficient, which in turn supports tools like "mise."

  7. sohamsakhare76-ai commented on Oct 10, 2026

    @sohamsakhare76-ai
    Contributor

    Hey, I've investigated the environment-customization API and tested its availability against LSP4IJ's current IntelliJ Platform dependencies. CommandLineEnvCustomizer isn't available in our current 2024.2 compile target.

    It looks like we need to clarify the compatibility requirement before implementing the fix. Would you prefer to preserve support for IntelliJ 2024.2, or would conditional support for the newer environment-customization API be acceptable?

    I'd like to ensure the solution supports directory-specific environments generically, without introducing a dependency on Mise or breaking existing IDE compatibility.

  8. PassingByThs commented on Oct 10, 2026

    @PassingByThs
    Author

    I have always been using the latest version of IntelliJ IDEA, and currently I am using IntelliJ IDEA 2026.2.3. I do not require compatibility with older versions of IntelliJ IDEA.

  9. sohamsakhare76-ai commented on Oct 10, 2026

    @sohamsakhare76-ai
    Contributor

    Thanks for clarifying! Since the directory-environment customization API isn't available in LSP4IJ's current 2024.2 target, would you be open to raising the minimum supported IntelliJ Platform version to 2026.1 to use the newer API? I'd like to confirm this before changing the build configuration.

  10. PassingByThs commented on Oct 10, 2026

    @PassingByThs
    Author

    I am not a plugin developer; I am simply using IntelliJ IDEA 2026.2.3, so this does not involve the minimum supported version of the IntelliJ Platform.

  11. sohamsakhare76-ai commented on Oct 10, 2026

    @sohamsakhare76-ai
    Contributor

    Thanks for clarifying! Just to clarify, my question about raising the minimum supported IntelliJ Platform version was directed to Angelo/the LSP4IJ maintainers, since I understand that this is a project-level compatibility decision rather than something the issue reporter would decide.

    I’ll continue investigating the API and the implementation in the meantime.

  12. angelozerr commented on Oct 10, 2026

    @angelozerr
    Contributor

    @sohamsakhare76-ai let me explain shortly the LSP4IJ history.

    In 2019, https://github.com/redhat-developer/intellij-quarkus has been created and as it didn't exist LSP support for JetBrains, LSP support was implemented.

    In 2022, maintainers of https://github.com/redhat-developer/intellij-quarkus had no time to maintain it and I was assigned to work on it. I decided to extract this LSP support in a new project LSP4IJ because I was sure that other plugins need LSP support. LSP4IJ was bad (a lot of performance problem , a lot of bugs), but after 1 year of hard work, LSP4IJ started to work correctly.

    I am the only author/maintainer of LSP4IJ and as we need DAP support in https://github.com/redhat-developer/intellij-quarkus (to support Qute debugger), I decided to provide DAP support in LSP4IJ.

    There are a lot of plugins which are based on LSP4IJ https://github.com/redhat-developer/lsp4ij/tree/main#who-is-using-lsp4ij so we cannot change the minimal version as we wish. We need to speak about that in discussion like I did with release #1646 (by adding authors of plugin).

    I have tried to cover 1 year compability. Today I don't use some 2025 or 2026 API, it is the reason why it is compatbible with 2024.

    In other words, it is really annoying to switch to 2026 just for a minor feature.

    Anyway thanks so much to investigate this issue.

  13. sohamsakhare76-ai commented on Oct 10, 2026

    @sohamsakhare76-ai
    Contributor

    Hi Angelo,

    I've investigated the LSP and DAP launch paths and the IntelliJ Platform 2024.2 APIs.

    Currently, both paths use the IDE's environment map, and setting a working directory alone doesn't resolve directory-specific environment variables.

    I haven't found a suitable public API in the 2024.2 sources for retrieving the environment associated with an arbitrary directory. Shell-based solutions also depend on how directory-specific environment tools integrate with the shell.

    Would you prefer us to implement a shared shell-based environment resolver, or is there an existing IntelliJ API or integration you recommend using while preserving compatibility with 2024.2?

    I'd like to keep the implementation generic rather than hard-code support for mise.

  14. angelozerr commented on Oct 10, 2026

    @angelozerr
    Contributor

    @sohamsakhare76-ai I know it is not a clean solution (but we do that sometimes to cover all IJ version), what about using CommandLineEnvCustomizer with Java Reflection?

    It will work with 2026 and not with 2024 (but it is not a problem)

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions