emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.82k stars 895 forks source link

`elm make` Fails After Starting Elm Language Server #3430

Open tmciver-mackey opened 2 years ago

tmciver-mackey commented 2 years ago

Thank you for the bug report

Bug description

Starting lsp in a buffer containing an Elm source file with elm-mode activated causes the following text to be displayed in *lsp-log*:

Command "/home/tim/.nvm/versions/node/v16.4.0/bin/elm-language-server --stdio" is present on the path.
Command "/home/tim/.nvm/versions/node/v16.4.0/bin/elm-language-server --stdio" is present on the path.
Found the following clients for /home/tim/workspace/front-end/elm/src/Layout/SearchBox.elm: (server-id elm-ls, priority -1)
The following clients were selected based on priority: (server-id elm-ls, priority -1)
Loading Elm tree-sitter syntax from ../../.nvm/versions/node/v16.4.0/lib/node_modules/@elm-tooling/elm-language-server/out/tree-sitter-elm.wasm
Found 2 elm.json files for workspace /home/tim/workspace/front-end
Found 1 unique elmWorkspaces for workspace /home/tim/workspace/front-end
Starting language server for folder: file:///home/tim/workspace/front-end
Elm version 0.19.1 detected.
Reading elm.json from /home/tim/workspace/front-end/elm.json
{"shortMessage":"Command failed with exit code 1: elm make","command":"elm make","escapedCommand":"elm make","exitCode":1,"stdout":"","stderr":"-- NO INPUT --------------------------------------------------------------------\n\nWhat should I make though? I need specific files like:\n\n    elm make src/Main.elm\n    elm make src/This.elm src/That.elm\n\nI recommend reading through https://guide.elm-lang.org for guidance on what to\nactually put in those files!\n\n","failed":true,"timedOut":false,"isCanceled":false,"killed":false}
Error parsing files for /home/tim/workspace/front-end/elm.json:
Error: ENOENT: no such file or directory, open '/home/tim/.elm/0.19.1/packages/ContaSystemer/elm-menu/1.1.1/elm.json'
Notification handler 'textDocument/didOpen' failed with message: Cannot read property 'getTree' of undefined
TypeError: Cannot read property 'getTree' of undefined delayed processing of request

Steps to reproduce

Install elm-laguage-server globally with

npm i -g @elm-tooling/elm-language-server

Create a fresh emacs environment by (re)moving any current emacs configuration and putting the following in a new $HOME/.emacs/init.el:

(require 'package)

(setq package-archives '(("org" . "https://orgmode.org/elpa/")
                         ("gnu" . "https://elpa.gnu.org/packages/")
                         ("melpa" . "https://melpa.org/packages/")))

;; initialize built-in package management
(package-initialize)

;; update packages list if we are on a new install
(unless package-archive-contents
  (package-refresh-contents))

(exec-path-from-shell-initialize)

Start emacs. Run package-list-packages and install elm-mode and lsp-mode. Restart emacs. Open an Elm source file and ensure that elm-mode is activated. Start lsp-mode withM-x lsp. Observe that elm-language-server starts and stays running but produces the error mentioned above in *lsp-log*.

Expected behavior

No error when starting lsp.

Which Language Server did you use?

elm-language-server version 2.4.1.

OS

Linux

Error callstack

Command "/home/tim/.nvm/versions/node/v16.4.0/bin/elm-language-server --stdio" is present on the path.
Command "/home/tim/.nvm/versions/node/v16.4.0/bin/elm-language-server --stdio" is present on the path.
Found the following clients for /home/tim/workspace/front-end/elm/src/Layout/SearchBox.elm: (server-id elm-ls, priority -1)
The following clients were selected based on priority: (server-id elm-ls, priority -1)
Loading Elm tree-sitter syntax from ../../.nvm/versions/node/v16.4.0/lib/node_modules/@elm-tooling/elm-language-server/out/tree-sitter-elm.wasm
Found 2 elm.json files for workspace /home/tim/workspace/front-end
Found 1 unique elmWorkspaces for workspace /home/tim/workspace/front-end
Starting language server for folder: file:///home/tim/workspace/front-end
Elm version 0.19.1 detected.
Reading elm.json from /home/tim/workspace/front-end/elm.json
{"shortMessage":"Command failed with exit code 1: elm make","command":"elm make","escapedCommand":"elm make","exitCode":1,"stdout":"","stderr":"-- NO INPUT --------------------------------------------------------------------\n\nWhat should I make though? I need specific files like:\n\n    elm make src/Main.elm\n    elm make src/This.elm src/That.elm\n\nI recommend reading through https://guide.elm-lang.org for guidance on what to\nactually put in those files!\n\n","failed":true,"timedOut":false,"isCanceled":false,"killed":false}
Error parsing files for /home/tim/workspace/front-end/elm.json:
Error: ENOENT: no such file or directory, open '/home/tim/.elm/0.19.1/packages/ContaSystemer/elm-menu/1.1.1/elm.json'
Notification handler 'textDocument/didOpen' failed with message: Cannot read property 'getTree' of undefined
TypeError: Cannot read property 'getTree' of undefined delayed processing of request

Anything else?

I'm running emacs version 28.0.91 installed using Nix.

yyoncho commented 2 years ago

To me, it looks like something that has to be investigated on the server side first. Can you ask in their channels?

tmciver-mackey commented 2 years ago

OK, thank you. I've created an elm-language-server issue here.