Skip to content

Commit

Permalink
chore: Add a warning when ignoring JAVA_HOME set by Metals
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Jun 17, 2024
1 parent 70d7650 commit b8d7199
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions metals/src/main/scala/scala/meta/internal/bsp/BspServers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,17 @@ final class BspServers(
// With Bazel for example chaning JAVA_HOME might cause Bazel to restart on shell
if (
sys.env.contains("JAVA_HOME") && details.getName().contains("bazel")
) Map.empty[String, String]
else JdkSources.envVariables(userConfig().javaHome)
) {
userConfig().javaHome.zip(sys.env.get("JAVA_HOME")) match {
case Some((metalsHome, envHome)) if metalsHome != envHome =>
scribe.warn(
s"JAVA_HOME set by Metals (${metalsHome}) would be different than the one set in the environment ($envHome), " +
"which might cause Bazel to restart on shell, so Metals will not override it."
)
case _ =>
}
Map.empty[String, String]
} else JdkSources.envVariables(userConfig().javaHome)
scribe.info(s"Running BSP server $args")
val proc = SystemProcess.run(
args,
Expand Down

0 comments on commit b8d7199

Please sign in to comment.