Skip to content

Replace PathEnvironmentVariableUtil with JDK standard library#64

Merged
davydkov merged 3 commits into
codex/enhance-plugin-to-check-likec4-language-serverfrom
copilot/fix-ci-build-error
Feb 5, 2026
Merged

Replace PathEnvironmentVariableUtil with JDK standard library#64
davydkov merged 3 commits into
codex/enhance-plugin-to-check-likec4-language-serverfrom
copilot/fix-ci-build-error

Conversation

Copilot AI commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

PathEnvironmentVariableUtil is unavailable in IntelliJ Platform 2024.3, breaking compilation of LikeC4LanguageServerInstaller.

Changes

  • Removed dependency on com.intellij.execution.util.PathEnvironmentVariableUtil
  • Implemented PATH lookup using System.getenv("PATH") and java.nio.file.Files.isExecutable()
  • Added Windows extension handling (.cmd, .bat, .exe) to match platform conventions

Implementation

private fun isAvailable(): Boolean {
  val paths = System.getenv("PATH")?.split(System.getProperty("path.separator")) ?: return false
  val extensions = if (SystemInfo.isWindows) listOf(".cmd", ".bat", ".exe", "") else listOf("")
  
  return paths.any { pathDir ->
    extensions.any { ext ->
      val executablePath = java.nio.file.Paths.get(pathDir, executableName + ext)
      java.nio.file.Files.isExecutable(executablePath)
    }
  }
}

The replacement maintains cross-platform compatibility while using only JDK APIs.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.jetbrains.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

The build fails in CI due to unresolved reference 'PathEnvironmentVariableUtil' in 'LikeC4LanguageServerInstaller.kt'. This is likely because 'com.intellij.execution.util.PathEnvironmentVariableUtil' is missing from the dependencies or not available in the targeted IntelliJ Platform SDK version. To ensure compatibility and address the error, remove usage of 'PathEnvironmentVariableUtil' and replace it with a generic executable lookup using Java/Kotlin standard libraries. Specifically, rewrite the 'isAvailable()' function in LikeC4LanguageServerInstaller.kt to manually check if the executable exists anywhere in PATH, using only standard JDK APIs. Do not depend on PathEnvironmentVariableUtil or any other missing IDE utility. This will restore compatibility and fix the CI build.

Example replacement:
Replace:
import com.intellij.execution.util.PathEnvironmentVariableUtil
...
private fun isAvailable(): Boolean =
PathEnvironmentVariableUtil.findExecutableInPath(executableName) != null

With:
private fun isAvailable(): Boolean =
System.getenv("PATH")
?.split(System.getProperty("path.separator"))
?.map { java.nio.file.Paths.get(it, executableName) }
?.any { java.nio.file.Files.isExecutable(it) }
?: false

Remove the unused import statement as well.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 5, 2026 11:07
Co-authored-by: davydkov <824903+davydkov@users.noreply.github.com>
…upport

Co-authored-by: davydkov <824903+davydkov@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unresolved reference in LikeC4LanguageServerInstaller Replace PathEnvironmentVariableUtil with JDK standard library Feb 5, 2026
Copilot AI requested a review from davydkov February 5, 2026 11:12
@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Qodana Community for JVM

1 new problem were found

Inspection name Severity Problems
Call to 'System.getProperty(str)' could be simplified 🔶 Warning 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2025.2.3
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@davydkov davydkov marked this pull request as ready for review February 5, 2026 11:57
@davydkov davydkov merged commit e9fe4c9 into codex/enhance-plugin-to-check-likec4-language-server Feb 5, 2026
6 checks passed
@davydkov davydkov deleted the copilot/fix-ci-build-error branch February 5, 2026 11:57
davydkov added a commit that referenced this pull request Feb 5, 2026
* Warn when LikeC4 language server is missing

* Fix npm install command for Windows

* Replace PathEnvironmentVariableUtil with JDK standard library (#64)

* Initial plan

* Replace PathEnvironmentVariableUtil with standard JDK APIs

Co-authored-by: davydkov <824903+davydkov@users.noreply.github.com>

* Add Windows executable extension handling for better cross-platform support

Co-authored-by: davydkov <824903+davydkov@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: davydkov <824903+davydkov@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants