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

coc.nvim fails to start language server with error about "unregistered dependency token ElmWorkspaces" #695

Closed
patreeceeo opened this issue May 21, 2022 · 12 comments · Fixed by #881

Comments

@patreeceeo
Copy link

patreeceeo commented May 21, 2022

I've used coc.nvim for a while with a variety of languages and I'm trying to get started with Elm. I've installed this language server and its dependencies in my local node_modules directory and configured coc.nvim like so:

{
  ...
    "elmLS": {
      "command": "./assets/node_modules/.bin/elm-language-server",
      "filetypes": ["elm"],
      "rootPatterns": ["elm.json"],
      "elmPath": "./assets/node_modules/.bin/elm",
      "elmReviewPath": "./assets/node_modules/.bin/elm-review",
      "elmFormatPath": "./assets/node_modules/.bin/elm-format",
      "elmTestPath": "./assets/node_modules/.bin/elm-test",
    },
   ...
}

Expected Behavior

coc.nvim starts the language server and I can write Elm code using neovim and code completion, syntax checking etc.

Current Behavior

When I start coc.nvim it gives me this message:

Server languageserver.elmLS failed to start: Pm [Error]: Request
initialize failed with message: Attempted to resolve unregistered dependency token: "ElmWorkspaces"
at su (/home/patrick/dotfiles/.config/nvim/plugged/coc.nvim/build/index.js:38:224)
lp (/home/patrick/dotfiles/.config/nvim/plugged/coc.nvim/build/index.js:37:11261)
at
at Immediate. <anonymous> (/home/patrick/dotfiles/.config/nvim/plugged/coc.nvim/build/index.js:37:11111)
at process Immediate (node: internal/timers:464:21) {
code: -32603,
data: undefined

Possible Solution

Not sure I can help here just yet. Was looking through the source of both coc.nvim and elm-language-server and it's hard to tell where this error is even coming from. I suspect it's from a dependency of elm-language-server.

Steps to Reproduce

  1. Install elm-language-server and its dependencies
  2. Configure coc.nvim
  3. Edit a Elm file

Your Environment

  • Version used: 1.6.0
  • Editor used: neovim 0.4.3
  • Environment name and version: Node 16.3.0
  • Operating System and version: Ubuntu 20.04
@patreeceeo
Copy link
Author

patreeceeo commented May 21, 2022

Just tried installing everything globally ( -g @elm-tooling/elm-language-server elm-format elm-test elm-review) and changing my coc.nvim config to:

{
  ...
    "elmLS": {
      "command": "elm-language-server",
      "filetypes": ["elm"],
      "rootPatterns": ["elm.json"]
    },
  ...
}

But same result.

@patreeceeo
Copy link
Author

Same result with the latest release of neovim, 0.7.0

@razzeee
Copy link
Member

razzeee commented May 22, 2022

Seems like the dependency injection fails for some reason. Probably because vim fails to find a workspace?

@patreeceeo
Copy link
Author

That gives me an idea... Yup, it must have been because I hadn't created an elm.json file yet. Now that that exists in an ancestor directory to the file I'm editing the LS starts up successfully. So, user error, though in the friendly spirit of Elm perhaps the error message should be more helpful?

@razzeee
Copy link
Member

razzeee commented May 24, 2022

Hrm, is there something else that's weird? I can't reproduce this in vscode. I took a project and just deleted the elm.json and reloaded the workspace.

@AndydeCleyre
Copy link

I get the same problem with LSP-elm in sublime text. I'm just going through elm tutorials for the first time so I don't have any idea what ElmWorkspaces is yet.

@razzeee
Copy link
Member

razzeee commented Nov 10, 2022

That's an internal thing to the language server, you won't know that from learning elm

@mattiasdrp
Copy link

I have the same issue in emacs:

❯ elm-language-server --version
2.6.0
❯ node -v
v16.19.0

I created an empty project with elm init and opened src/Main.elm and got the exact same message and the lsp-log error displayed

No elm.json found. Please run 'elm init' in your main directory.
No elm.json found

But

❯ tree
.
├── elm.json
└── src
    └── Main.elm

@tillydray
Copy link

I'm also having this same issue in emacs.

Your Environment

  • Version used: 1.12.0
  • Editor used: Doom Emacs GNU Emacs 28.2 (build 1, aarch64-apple-darwin22.2.0, Carbon - Version 169 AppKit 2299.3) of 2023-01-22
  • Environment name and version: Node v16.19.0
  • Operating System and version: macOS 13.1

@mattiasdrp
Copy link

@tillydray As you can see from emacs-lsp/lsp-mode#3936, my issue is that projectile was not setting the project root properly. I created a PR for Projectile: bbatsov/projectile#1819.
Do you have the same root issue? In this case, try to set it manually to not include src.

@razzeee the issue doesn't come from the elm language server, sorry for the disturbance 😉

@tillydray
Copy link

tillydray commented Jan 30, 2023 via email

@mattiasdrp
Copy link

Glad you had the same issue. At least it's consistent!

razzeee added a commit that referenced this issue Jan 30, 2023
razzeee added a commit that referenced this issue Feb 1, 2023
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 a pull request may close this issue.

5 participants