Lsp-mode: Wrong scala project root path detected when using lsp-metals.

Created on 13 May 2020  路  2Comments  路  Source: emacs-lsp/lsp-mode

Describe the bug
Wrong scala project root path detected.

Command "metals-emacs" is present on the path.
Found the following clients for /home/madper/source/mon/src/main/scala/Main.scala: (server-id metals, priority -1)
The following clients were selected based on priority: (server-id metals, priority -1)
2020.05.14 00:42:35 INFO  logging to file /home/madper/.metals/metals.log
2020.05.14 00:42:35 INFO  started: Metals version 0.9.0 in workspace '/home/madper'
2020.05.14 00:42:36 INFO  time: initialize in 0.67s
Creating watch for /home/madper
2020.05.14 00:42:40 INFO  skipping build import with status 'Requested'

The build.sbt located in /home/madper/source/mon/build.sbt. (And there is no /home/madper/build.sbt). Not sure why it use /home/madper as project root.

To Reproduce

  1. sbt new scala/hello-world.g8
  2. sbt compile it
  3. open the scala source file with emacs
  4. check the lsp-log buffer.

Expected behavior
The project root should be the real project root.

Which Language Server did you use
lsp-metals

OS
Archlinux

Error callstack

[Trace - 12:42:35 AM] Sending request 'initialize - (1)'.
Params: {
  "processId": null,
  "rootPath": "/home/madper",
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 28.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version 3.24.17, cairo version 1.17.3)\n of 2020-04-30"
  },
  "rootUri": "file:///home/madper",
  "capabilities": {
    "workspace": {
      "workspaceEdit": {
        "documentChanges": true,
        "resourceOperations": [
          "create",
          "rename",
          "delete"
        ]
      },

Most helpful comment

This is what you have selected as a root. Lsp-mode uses projectile or project.el to guess the root but it is always confirmed by the user by default. To validate that do M-x lsp-workspace-folders-remove and then reopen that file.

All 2 comments

This is what you have selected as a root. Lsp-mode uses projectile or project.el to guess the root but it is always confirmed by the user by default. To validate that do M-x lsp-workspace-folders-remove and then reopen that file.

Aha, you are correct. Thanks tons for the help! :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcraveiro picture mcraveiro  路  3Comments

lukertty picture lukertty  路  5Comments

raxod502 picture raxod502  路  5Comments

MaskRay picture MaskRay  路  5Comments

raxod502 picture raxod502  路  4Comments