Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On some errors metals spawning multiply Open Doctor questions dialogs and stealing focus from user. #6988

Closed
strobe opened this issue Nov 29, 2024 · 31 comments · Fixed by #7052
Assignees
Labels
bloop Bloop related tickets bug Something that is making a piece of functionality unusable upstream-fix-needed Waiting on a fix upstream

Comments

@strobe
Copy link
Contributor

strobe commented Nov 29, 2024

Describe the bug

I seen this behavior multiply times in different version but would like to provide some details on recent one.

Usually it happens with editing project build definition (in my case build.sc, but I seen same happen with build.sbt too).

On file save the 'Open Doctor' dialog appears and then editor focus moving to it. But issue that it's not only stealing focus but also that it's creating about 5 dialogs at same time and user required to click on each one to close it. Also, after those dialogs will appears on next file safe again (no matter how much time since previous save).
image

So basically with that almost not possible to edit any build files. I seen that also happening with usual code but that definitely more rare cases, seems build file editing triggering that almost always.

@dos65 tried to check issue little bit, he provided this patch dos65@db5e731

and with metals version compiled from that branch following messages found in lsp-client log:

[eglot] Server reports (type=2): Bloop 1 : Referring to non-existent method static org.scalajs.testing.bridge.Bridge.start()void
[eglot] Server reports (type=2): Bloop 2 : called from core module module initializers
[eglot] Server reports (type=2): Bloop 3 : Referring to non-existent class org.scalajs.testing.bridge.Bridge
[eglot] Server reports (type=2): Bloop 3 : called from core module module initializers
[eglot] Server reports (type=2): Bloop 4 : JavaScript linking failed with 'There were linking errors'
[eglot] Server reports (type=2): Bloop 4 : Referring to non-existent method static org.scalajs.testing.bridge.Bridge.start()void
[eglot] Server reports (type=2): Bloop 4 : called from core module module initializers
[eglot] Server reports (type=2): Bloop 4 : Referring to non-existent class org.scalajs.testing.bridge.Bridge
[eglot] Server reports (type=2): Bloop 4 : called from core module module initializers
[eglot] Server reports (type=2): Bloop 4 : JavaScript linking failed with 'There were linking errors'
[eglot] Server reports (type=2): Bloop 4 : Referring to non-existent method static org.scalajs.testing.bridge.Bridge.start()void
[eglot] Server reports (type=2): Bloop 4 : called from core module module initializers
[eglot] Server reports (type=2): Bloop 4 : Referring to non-existent class org.scalajs.testing.bridge.Bridge
[eglot] Server reports (type=2): Bloop 4 : called from core module module initializers
[eglot] Server reports (type=2): Bloop 4 : JavaScript linking failed with 'There were linking errors'

Also following error presented in metals.log

2024.11.28 16:54:18 WARN  Unable to run doctor. Make sure `isHttpEnabled` is set to `true`. [0m
2024.11.28 16:54:27 ERROR unexpected error during source scanning
scala.meta.internal.tokenizers.package$UnexpectedInputEndException
  at scala.meta.internal.tokenizers.LegacyScanner.$anonfun$nextToken$1(LegacyScanner.scala:172)
  at scala.Function0.apply$mcV$sp(Function0.scala:42)
  at scala.meta.internal.tokenizers.LegacyScanner.scala$meta$internal$tokenizers$LegacyScanner$$nextToken(LegacyScanner.scala:178)
  at scala.meta.internal.tokenizers.LegacyScanner.nextToken(LegacyScanner.scala:172)
  at scala.meta.internal.mtags.ScalaToplevelMtags$XtensionScanner.mtagsNextToken(ScalaToplevelMtags.scala:76)
  at scala.meta.internal.mtags.ScalaToplevelMtags.loop$3(ScalaToplevelMtags.scala:966)
  at scala.meta.internal.mtags.ScalaToplevelMtags.acceptWhileIndented(ScalaToplevelMtags.scala:980)
  at scala.meta.internal.mtags.ScalaToplevelMtags.loop(ScalaToplevelMtags.scala:365)
  at scala.meta.internal.mtags.ScalaToplevelMtags.indexRoot(ScalaToplevelMtags.scala:88)
  at scala.meta.internal.mtags.MtagsIndexer.index(MtagsIndexer.scala:21)
  at scala.meta.internal.mtags.MtagsIndexer.index$(MtagsIndexer.scala:20)
  at scala.meta.internal.mtags.ScalaToplevelMtags.index(ScalaToplevelMtags.scala:48)
  at scala.meta.internal.mtags.Mtags.indexWithOverrides(Mtags.scala:74)
  at scala.meta.internal.mtags.SymbolIndexBucket.indexSource(SymbolIndexBucket.scala:129)
  at scala.meta.internal.mtags.SymbolIndexBucket.addSourceFile(SymbolIndexBucket.scala:108)
  at scala.meta.internal.mtags.SymbolIndexBucket.$anonfun$addSourceJar$2(SymbolIndexBucket.scala:72)
  at scala.collection.immutable.List.flatMap(List.scala:294)
  at scala.meta.internal.mtags.SymbolIndexBucket.$anonfun$addSourceJar$1(SymbolIndexBucket.scala:70)
  at scala.meta.internal.io.PlatformFileIO$.withJarFileSystem(PlatformFileIO.scala:77)
  at scala.meta.internal.io.FileIO$.withJarFileSystem(FileIO.scala:33)
  at scala.meta.internal.mtags.SymbolIndexBucket.addSourceJar(SymbolIndexBucket.scala:68)
  at scala.meta.internal.mtags.OnDemandSymbolIndex.$anonfun$addSourceJar$2(OnDemandSymbolIndex.scala:85)
...

Env

Editor

Emacs 29.4 (with doom-emacs)

Lsp client

eglot

OS

Linux (NixOS 24.05)

jdk

openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9)
OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode, sharing)

build tool

mill 0.12.1
(with scala project which included ScalaJS usage)

Expected behavior

editor never steal focus from user (except new project opening case)

Operating system

Linux

Editor/Extension

Emacs (other)

Version of Metals

v1.4.1, v1.4.2

Extra context or search terms

doctor

@strobe
Copy link
Contributor Author

strobe commented Nov 29, 2024

forgot to mention that even when that Open Doctor dialog main Metals functionality working as expected (auto competition works)

@tgodzik
Copy link
Contributor

tgodzik commented Nov 29, 2024

I think that should already be fixed in #6960

You should also be able to change the client configuration the same way in the current version

@tgodzik tgodzik added the needs more information Use if we need more information for a specific ticket label Nov 29, 2024
@strobe
Copy link
Contributor Author

strobe commented Nov 29, 2024

just tested it (without any extra client configuration) via 'quick-publish-local' and that doesn't change behavior in any way, 'Open Doctor' still appears and still spawning multiply requests.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 29, 2024

Ach, right! I only had a quick look at the issue and didn't realize this is a different things altogether.

@tgodzik tgodzik added bug Something that is making a piece of functionality unusable bloop Bloop related tickets upstream-fix-needed Waiting on a fix upstream and removed needs more information Use if we need more information for a specific ticket labels Nov 29, 2024
@tgodzik
Copy link
Contributor

tgodzik commented Nov 29, 2024

We need to fix one issue upstream in Bloop and provide a way of disabling the pop up for users.

@tgodzik tgodzik assigned tgodzik and unassigned tgodzik Dec 4, 2024
@tgodzik
Copy link
Contributor

tgodzik commented Dec 4, 2024

Wait, It seems that this should already only log by default and not show message request. #6960 did basically that.

Maybe bspStatusBarState or statusBarState option is set to ShowMessage ? Otherwise we never default to it.

@tgodzik
Copy link
Contributor

tgodzik commented Dec 4, 2024

How is Metals configured in your case? I can't find any other case that this would fail.

@strobe
Copy link
Contributor Author

strobe commented Dec 4, 2024

I have very simple eglot config:

(use-package scala-mode
  :interpreter
    ("scala" . scala-mode))

(use-package eglot
:hook (
  (scala-mode . eglot-ensure)))

is unlikely that bspStatusBarState or statusBarStat configured on eglot side because it's does't has any configuration specific to metals (except https://github.com/joaotavora/eglot/blob/db91d58374627a195b731a61bead9b4f84a7e4bc/eglot.el#L269).

@strobe
Copy link
Contributor Author

strobe commented Dec 4, 2024

I later could try launch metals process with '-Dmetals.status-bar=off' just to be sure.

@tgodzik
Copy link
Contributor

tgodzik commented Dec 5, 2024

Maybe the issue is that there is actual support for metals/status -> https://github.com/emacs-lsp/lsp-metals/blob/master/lsp-metals.el#L830

And it's kind of working as expected? In VS Code the command is not prompted to the user.

@tgodzik
Copy link
Contributor

tgodzik commented Dec 5, 2024

And it looks to be on by deault https://github.com/emacs-lsp/lsp-metals/blob/master/lsp-metals.el#L875

@tgodzik
Copy link
Contributor

tgodzik commented Dec 5, 2024

As for the error itself, Referring to non-existent class org.scalajs.testing.bridge.Bridge looks like an issue with classpath, but I have no idea where. Some smaller scala js projects do not have that issue 🤔

@tgodzik
Copy link
Contributor

tgodzik commented Dec 5, 2024

Last I saw it was in scalacenter/bloop#1234

@strobe
Copy link
Contributor Author

strobe commented Dec 5, 2024

@tgodzik
Is 2 main ways to use LSP with emacs:

  1. eglot which part of emacs master branch now and included with it by default.
  2. lsp-mode package with lsp-metals

This issue only about first case.

eglot project has different ideology than lsp-mode they trying to make it sufficient with very minimal set of features so it can be part of emacs. Is expectation that every LSP can work with it almost with default configuration so creating something like lsp-metals for it doesn't has much sense. However it might be ok to try set some parameters in config and put it to metals doc if that will work.

@strobe
Copy link
Contributor Author

strobe commented Dec 5, 2024

I will try to test it with -Dmetals.status-bar=off later today.

About scalaJs example project I actually have plans to do that for different purpose but not sure on time-frame about that.

@tgodzik
Copy link
Contributor

tgodzik commented Dec 5, 2024

If you find a reproduction for that bridge issue do let me know, I might be able to work in it in Bloop. I will also keep my eyes peeled for that error.

@strobe
Copy link
Contributor Author

strobe commented Dec 6, 2024

tested it with -Dmetals.status-bar=off -Dmetals.bsp-status-bar=log-message
image

it doesn't helps and OpenDoctor thing showing up anyway.

@tgodzik
Copy link
Contributor

tgodzik commented Dec 6, 2024

That's unexpected, could you create .metals/lsp.trace.json file and check what is being sent at the start in the initialization options? That's usually taken first before the properties

@tgodzik
Copy link
Contributor

tgodzik commented Dec 6, 2024

I will also add some debug for the future that can be activated with -Dmetals.loglevel=debug #7014

@tgodzik
Copy link
Contributor

tgodzik commented Dec 6, 2024

It seems it must be defined somewhere else, since the defaults do not show messages for Metals. There needs to be some configuration somewhere.

What is https://github.com/joaotavora/eglot/blob/master/eglot.el#L270 these references? What is metals-emacs in this case and how does it know how to set it up?

@strobe
Copy link
Contributor Author

strobe commented Dec 9, 2024

I will test it with 'debug' and trace at evening.

What is https://github.com/joaotavora/eglot/blob/master/eglot.el#L270 these references? What is metals-emacs in this case and how does it know how to set it up?

thast possible names of program to run.

it just looking for program in PATH and if no any then it asking user to provide command (is how I able to launch it with -Dmetals.status-bar=off).

Im testing it by putting metals file to ~/.local/bin/ (without any other version installed)

@kasiaMarek
Copy link
Contributor

BTW all these messages come from BSP status. You can make it log info instead of showing the dialog by adding a server property -Dmetals.bsp-status-bar=log-message.

@strobe
Copy link
Contributor Author

strobe commented Dec 9, 2024

@kasiaMarek as I mention in discussion above I already tested it with -Dmetals.bsp-status-bar=log-message and anyway got Open Doctor dialog with that.

@kasiaMarek
Copy link
Contributor

@kasiaMarek as I mention in discussion above I already tested it with -Dmetals.bsp-status-bar=log-message and anyway got Open Doctor dialog with that.

O sorry, my bad for not reading the whole thread.

@strobe
Copy link
Contributor Author

strobe commented Dec 10, 2024

@tgodzik
here is part of .metals/lsp.trace.json

[Trace - 01:03:29 PM] Received request 'initialize - (1)'
Params: {
  "processId": 1034583,
  "rootPath": "/home/evgeniy/dev/<SOME_PATH>/<SOME_PATH>/",
  "rootUri": "file:///home/evgeniy/dev/<SOME_PATH>/<SOME_PATH>",
  "initializationOptions": {},
  "capabilities": {
    "workspace": {
      "applyEdit": true,
      "workspaceEdit": {
        "documentChanges": true
      },
      "didChangeWatchedFiles": {
        "dynamicRegistration": true
      },
      "symbol": {
        "dynamicRegistration": false
      },
      "executeCommand": {
        "dynamicRegistration": false
      },
      "workspaceFolders": true,
      "configuration": true
    },
    "textDocument": {
      "synchronization": {
        "willSave": true,
        "willSaveWaitUntil": true,
        "didSave": true,
        "dynamicRegistration": false
      },
      "completion": {
        "completionItem": {
          "snippetSupport": true,
          "deprecatedSupport": true,
          "tagSupport": {
            "valueSet": [
              1
            ]
          },
          "resolveSupport": {
            "properties": [
              "documentation",
              "details",
              "additionalTextEdits"
            ]
          }
        },
        "contextSupport": true,
        "dynamicRegistration": false
      },
      "hover": {
        "contentFormat": [
          "markdown",
          "plaintext"
        ],
        "dynamicRegistration": false
      },
      "signatureHelp": {
        "signatureInformation": {
          "documentationFormat": [
            "markdown",
            "plaintext"
          ],
          "parameterInformation": {
            "labelOffsetSupport": true
          },
          "activeParameterSupport": true
        },
        "dynamicRegistration": false
      },
      "references": {
        "dynamicRegistration": false
      },
      "documentHighlight": {
        "dynamicRegistration": false
      },
      "documentSymbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        },
        "hierarchicalDocumentSymbolSupport": true,
        "dynamicRegistration": false
      },
      "formatting": {
        "dynamicRegistration": false
      },
      "rangeFormatting": {
        "dynamicRegistration": false
      },
      "declaration": {
        "linkSupport": true,
        "dynamicRegistration": false
      },
      "definition": {
        "linkSupport": true,
        "dynamicRegistration": false
      },
      "typeDefinition": {
        "linkSupport": true,
        "dynamicRegistration": false
      },
      "implementation": {
        "linkSupport": true,
        "dynamicRegistration": false
      },
      "codeAction": {
        "codeActionLiteralSupport": {
          "codeActionKind": {
            "valueSet": [
              "quickfix",
              "refactor",
              "refactor.extract",
              "refactor.inline",
              "refactor.rewrite",
              "source",
              "source.organizeImports"
            ]
          }
        },
        "isPreferredSupport": true,
        "dataSupport": true,
        "resolveSupport": {
          "properties": [
            "edit",
            "command"
          ]
        },
        "dynamicRegistration": false
      },
      "rename": {
        "dynamicRegistration": false
      },
      "publishDiagnostics": {
        "relatedInformation": false,
        "tagSupport": {
          "valueSet": [
            1,
            2
          ]
        },
        "codeDescriptionSupport": false
      },
      "inlayHint": {
        "dynamicRegistration": false
      }
    },
    "window": {
      "workDoneProgress": true,
      "showDocument": {
        "support": true
      }
    },
    "general": {
      "positionEncodings": [
        "utf-32",
        "utf-8",
        "utf-16"
      ]
    },
    "experimental": {}
  },
  "clientInfo": {
    "name": "Eglot",
    "version": "1.17"
  },
  "workspaceFolders": [
    {
      "uri": "file:///home/evgeniy/dev/<SOME_PATH>/<SOME_PATH>",
      "name": "/home/evgeniy/dev/<SOME_PATH>/<SOME_PATH>/"
    }
  ]
}


[Trace - 01:03:29 PM] Sending notification 'window/logMessage'
Params: {
  "type": 4,
  "message": "2024.12.10 13:03:29 INFO  logging to files /home/evgeniy/dev/<SOME_PATH>/<SOME_PATH>/.metals/metals.log"
}


[Trace - 01:03:29 PM] Sending notification 'window/logMessage'
Params: {
  "type": 4,
  "message": "2024.12.10 13:03:29 INFO  Started: Metals version 1.4.2-SNAPSHOT in folders \u0027/home/evgeniy/dev/<SOME_PATH>/<SOME_PATH>\u0027 for client Eglot 1.17."
}


[Trace - 01:03:29 PM] Sending response 'initialize - (1)'. Processing request took 342ms
Result: {
  "capabilities": {
    "textDocumentSync": {
      "openClose": true,
      "change": 1,
      "save": {
        "includeText": true
      }
    },
    "hoverProvider": true,
    "completionProvider": {
      "resolveProvider": true,
      "triggerCharacters": [
        ".",
        "*"
      ]
    },
    "signatureHelpProvider": {
      "triggerCharacters": [
        "(",
        "[",
        ","
      ]
    },
    "definitionProvider": true,
    "typeDefinitionProvider": true,
    "implementationProvider": true,
    "referencesProvider": true,
    "documentHighlightProvider": true,
    "documentSymbolProvider": true,
    "workspaceSymbolProvider": true,
    "codeActionProvider": {
      "codeActionKinds": [
        "quickfix",
        "refactor",
        "source.organizeImports"
      ],
      "resolveProvider": true
    },
    "codeLensProvider": {
      "resolveProvider": false
    },
    "documentFormattingProvider": true,
    "documentRangeFormattingProvider": true,
    "documentOnTypeFormattingProvider": {
      "firstTriggerCharacter": "\n",
      "moreTriggerCharacter": [
        "\""
      ]
    },
    "renameProvider": {
      "prepareProvider": true
    },
    "foldingRangeProvider": true,
    "executeCommandProvider": {
      "commands": [
        "analyze-stacktrace",
        "zip-reports",
        "list-build-targets",
        "debug-adapter-start",
        "new-scala-file",
        "build-connect",
        "reset-workspace",
        "doctor-run",
        "insert-inferred-type",
        "insert-inferred-method",
        "discover-tests",
        "build-restart",
        "discover-jvm-run-command",
        "generate-bsp-config",
        "build-disconnect",
        "copy-worksheet-output",
        "presentation-compiler-restart",
        "browser-open-url:https://github.com/scalameta/metals-feature-requests/issues/new?template\u003dfeature-request.yml",
        "reset-choice",
        "goto",
        "open-new-github-issue",
        "new-scala-project",
        "ammonite-stop",
        "scalafix-run",
        "build-import",
        "inline-value",
        "sources-scan",
        "bsp-switch",
        "new-java-file",
        "reset-notifications",
        "extract-member-definition",
        "ammonite-start",
        "compile-cancel",
        "goto-super-method",
        "goto-position",
        "compile-cascade",
        "scala-cli-stop",
        "super-method-hierarchy",
        "scala-cli-start",
        "file-decode",
        "compile-clean",
        "scalafix-run-only"
      ]
    },
    "workspace": {
      "workspaceFolders": {
        "supported": true,
        "changeNotifications": true
      },
      "fileOperations": {
        "willRename": {
          "filters": [
            {
              "pattern": {
                "glob": "**/*.scala",
                "matches": "file"
              }
            },
            {
              "pattern": {
                "glob": "**/",
                "matches": "folder"
              }
            }
          ]
        }
      }
    },
    "callHierarchyProvider": true,
    "selectionRangeProvider": true,
    "semanticTokensProvider": {
      "legend": {
        "tokenTypes": [
          "namespace",
          "type",
          "class",
          "enum",
          "interface",
          "struct",
          "typeParameter",
          "parameter",
          "variable",
          "property",
          "enumMember",
          "event",
          "function",
          "method",
          "macro",
          "keyword",
          "modifier",
          "comment",
          "string",
          "number",
          "regexp",
          "operator",
          "decorator"
        ],
        "tokenModifiers": [
          "declaration",
          "definition",
          "readonly",
          "static",
          "deprecated",
          "abstract",
          "async",
          "modification",
          "documentation",
          "defaultLibrary"
        ]
      },
      "range": false,
      "full": true
    },
    "inlayHintProvider": {
      "resolveProvider": true
    },
    "experimental": {
      "rangeHoverProvider": true
    }
  },
  "serverInfo": {
    "name": "Metals",
    "version": "1.4.2-SNAPSHOT"
  }
}


[Trace - 01:03:29 PM] Received notification 'initialized'
Params: {}


[Trace - 01:03:29 PM] Sending request 'workspace/configuration - (1)'
Params: {
  "items": [
    {
      "scopeUri": "file:///home/evgeniy/dev/<SOME_PATH>/<SOME_PATH>/",
      "section": "metals"
    }
  ]
}


[Trace - 01:03:29 PM] Received notification 'textDocument/didOpen'
Params: {
  "textDocument": {
    "uri": "file:///home/evgeniy/dev/<SOME_PATH>/<SOME_PATH>/build.sc",
    "languageId": "scala",
    "version": 0,
    "text": "import $ivy.`com.github.lolgab::mill-scalablytyped::0.1.12`\nimport com.github.lolgab.mill.scalablytyped._\nimport coursier.maven.MavenRepository\nimport mill._\nimport mill.scalajslib._\nimport mill.scalajslib.api.{ESFeatures, ESVersion, ModuleKind}\nimport mill.scalalib._\nimport mill.scalalib.scalafmt._\n\ntrait <REMOVED SOME THINGS HERE...>"
  }
}

Also I noticed weird error in lsp.trace.json:

[Trace - 01:03:34 PM] Sending notification 'window/logMessage'
Params: {
  "type": 4,
  "message": "2024.12.10 13:03:34 ERROR Running process \u0027/nix/store/gyygbzav7iyz5ysvr2d50s4fag2apn5q-adoptopenjdk-hotspot-bin-11.0.19/bin/java -version\u0027 failed\njava.io.IOException: Cannot run program \"/nix/store/gyygbzav7iyz5ysvr2d50s4fag2apn5q-adoptopenjdk-hotspot-bin-11.0.19/bin/java\" (in directory \"/nix/store/gyygbzav7iyz5ysvr2d50s4fag2apn5q-adoptopenjdk-hotspot-bin-11.0.19\"): error\u003d2, No such file or directory\n\tat java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)\n\tat java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)\n\tat scala.meta.internal.process.SystemProcess$.run(SystemProcess.scala:48)\n\tat scala.meta.internal.builds.ShellRunner$.runSync(ShellRunner.scala:169)\n\tat scala.meta.internal.metals.JdkVersion$.fromShell(JavaInteractiveSemanticdb.scala:217)\n\tat scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$3(JavaInteractiveSemanticdb.scala:208)\n\tat scala.Option.orElse(Option.scala:477)\n\tat scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$2(JavaInteractiveSemanticdb.scala:208)\n\tat scala.Option.flatMap(Option.scala:283)\n\tat scala.meta.internal.metals.JdkVersion$.maybeJdkVersionFromJavaHome(JavaInteractiveSemanticdb.scala:206)\n\tat scala.meta.internal.metals.CompilerConfiguration.$anonfun$enrichWithReleaseOption$3(CompilerConfiguration.scala:376)\n\tat scala.Option.orElse(Option.scala:477)\n\tat scala.meta.internal.metals.CompilerConfiguration.optBuildTargetJvmVersion$1(CompilerConfiguration.scala:365)\n\tat scala.meta.internal.metals.CompilerConfiguration.scala$meta$internal$metals$CompilerConfiguration$$enrichWithReleaseOption(CompilerConfiguration.scala:381)\n\tat scala.meta.internal.metals.CompilerConfiguration$ScalaLazyCompiler.newCompiler(CompilerConfiguration.scala:170)\n\tat scala.meta.internal.metals.CompilerConfiguration$LazyCompiler.$anonfun$presentationCompilerFuture$2(CompilerConfiguration.scala:111)\n\tat scala.concurrent.impl.Promise$Transformation.run(Promise.scala:467)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.lang.Thread.run(Thread.java:840)\nCaused by: java.io.IOException: error\u003d2, No such file or directory\n\tat java.lang.ProcessImpl.forkAndExec(Native Method)\n\tat java.lang.ProcessImpl.\u003cinit\u003e(ProcessImpl.java:314)\n\tat java.lang.ProcessImpl.start(ProcessImpl.java:244)\n\tat java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)\n\tat java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)\n\tat scala.meta.internal.process.SystemProcess$.run(SystemProcess.scala:48)\n\tat scala.meta.internal.builds.ShellRunner$.runSync(ShellRunner.scala:169)\n\tat scala.meta.internal.metals.JdkVersion$.fromShell(JavaInteractiveSemanticdb.scala:217)\n\tat scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$3(JavaInteractiveSemanticdb.scala:208)\n\tat scala.Option.orElse(Option.scala:477)\n\tat scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$2(JavaInteractiveSemanticdb.scala:208)\n\tat scala.Option.flatMap(Option.scala:283)\n\tat scala.meta.internal.metals.JdkVersion$.maybeJdkVersionFromJavaHome(JavaInteractiveSemanticdb.scala:206)\n\tat scala.meta.internal.metals.CompilerConfiguration.$anonfun$enrichWithReleaseOption$3(CompilerConfiguration.scala:376)\n\tat scala.Option.orElse(Option.scala:477)\n\tat scala.meta.internal.metals.CompilerConfiguration.optBuildTargetJvmVersion$1(CompilerConfiguration.scala:365)\n\tat scala.meta.internal.metals.CompilerConfiguration.scala$meta$internal$metals$CompilerConfiguration$$enrichWithReleaseOption(CompilerConfiguration.scala:381)\n\tat scala.meta.internal.metals.CompilerConfiguration$ScalaLazyCompiler.newCompiler(CompilerConfiguration.scala:170)\n\tat scala.meta.internal.metals.CompilerConfiguration$LazyCompiler.$anonfun$presentationCompilerFuture$2(CompilerConfiguration.scala:111)\n\tat scala.concurrent.impl.Promise$Transformation.run(Promise.scala:467)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n\tat java.lang.Thread.run(Thread.java:840)\n"
}

so something trying to call adoptopenjdk-hotspot-bin-11.0.19 while default jdk in system temurin-bin-17.0.9 (and metals started with it) so it could be that scala.meta.internal.metals.JdkVersion$.fromShell getting wrong version for some reason.

Just in case that process looks like this:

/nix/store/gs1ahrmddk39d9q27pm337zjf16az1b3-temurin-bin-17.0.9/bin/java -Dsun.misc.URLClassPath.disableJarChecking -XX:+UseG1GC -XX:+UseStringDeduplication -Xss4m -Xms100m -jar /home/evgeniy/.local/bin/metals```

@tgodzik
Copy link
Contributor

tgodzik commented Dec 10, 2024

That seems another bug, worth raising a separate issue.

From your trace it indeed seems like bsp status is not enabled at all, so this should not be shown. I will try to repro this myself and see if maybe there is some weirdness.

@tgodzik
Copy link
Contributor

tgodzik commented Dec 19, 2024

OK, so my reproduction worked finally #7052

@strobe
Copy link
Contributor Author

strobe commented Dec 19, 2024

great to hear, thanks. I will try it tomorrow.

@tgodzik
Copy link
Contributor

tgodzik commented Dec 20, 2024

I have no idea how I didn't figure out earlier. Sorry it took so long!

@strobe
Copy link
Contributor Author

strobe commented Dec 21, 2024

just in case, I tested it and looks like 'Open Doctor' message no more appears.

Anyway, as result I got few more problems but those I able to resolve by myself, I just wanna share some details, just in case.
First I got this request appears every N seconds (like it triggered in the loop):

[Trace - 09:51:40 PM] Sending request 'window/showMessageRequest - (6)'
Params: {
  "actions": [
    {
      "title": "Turn off old server"
    },
    {
      "title": "I\u0027ll update manually"
    },
    {
      "title": "Don\u0027t show again"
    }
  ],
  "type": 2,
  "message": "You have Bloop 2.0.5 installed and Metals requires at least Bloop 2.0.6.\nIf you installed bloop via a system package manager (brew, aur, scoop), please upgrade manually.\nIf not, select \"Turn off old server\". A newer server will be started automatically afterwards.\n\n"
}

It's looks like some UX issue because it asking for user confirmation each time but that error can't be resolved in current editing session so I believe better approach there somehow to exit and allow user to continue his session with text editor without LSP.

Reason why I got that was because some wrong Jdk path values were cached inside project .bloop folder. It looks like it same issue as this #4053. I believe it something that causing lot of troubles no only with NixOS, I definitely recalling some cases which were caused by it on the MacOS as well. Part of this problem that is very unclear for user why Metals trying to use some specific JDK or Bloop version. So maybe one way to improve it is to provide information not only which version currently used but also extract reason why specific version selected by metals or bloop (probably in error messages and in doctor).

@tgodzik
Copy link
Contributor

tgodzik commented Dec 30, 2024

It's looks like some UX issue because it asking for user confirmation each time but that error can't be resolved in current editing session so I believe better approach there somehow to exit and allow user to continue his session with text editor without LSP.

We will be removing that most likely since most people don't understand what is going on, so it's not really useful.

Reason why I got that was because some wrong Jdk path values were cached inside project .bloop folder. It looks like it same issue as this #4053.

We should be picking up the same version as metals now. we no longer rely on global config. And Metals should be run with whichever version the boostrapped version is supposed to use, so most likely java on PATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bloop Bloop related tickets bug Something that is making a piece of functionality unusable upstream-fix-needed Waiting on a fix upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants