elm-language-client-vscode: elm-format fails

Expected Behavior

format file when saving or calling format action manually

Current Behavior

formating fails with

[Warn  - 13:12:09] {"shortMessage":"Command failed with exit code 127: elm-format --stdin --elm-version 0.19 --yes","command":"elm-format --stdin --elm-version 0.19 --yes","exitCode":127,"stdout":"","stderr":"env: node: No such file or directory\n","failed":true,"timedOut":false,"isCanceled":false,"killed":false}

elm-format is installed globally, also tried locally and explicit path in settings - same error with different path before elm-format

Possible Solution

Steps to Reproduce (for bugs)

  1. Setup project like proposed in readme
  2. Execute Format action of vscode

Context

Your Environment

  • Version used: 0.10.2
  • Editor name and version (e.g. VSCode 1.36.1): VSCode 1.45.1
  • Environment name and version (e.g. node.js 5.4): nodejs v14.3.0, elm 0.19.1
  • Operating System and version: macOS 10.15.4

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23 (9 by maintainers)

Most upvoted comments

Can you try to reinstall it? We recently had someone who thought it got stuck on install and aborted it and it still was callable from path.

Just setup a new machine and having the same issue. elm-format doesn’t run when I save.

  • I’ve tried uninstalling / reinstalling the VS code plugin
  • I can run elm-format from the command line
  • I have a elm.json in the root folder
  • I also have a elm-tooling.json in the root folder
  • I’ve open the project folder up in VS code (see my solution previously)
  • I’ve tried several different .elm files. Same result
  • I’ve tried setting the Elm Format Path directly

Not sure what else to try.

The Elm output in VS code looks fine. No mention of elm-format, though.

[Info  - 14:48:57] Find entrypoints: Using entrypoints from c:\Users\karlp\elm-aws\elm-tooling.json: ["./src/ElmUITest.elm"]. See https://github.com/elm-tooling/elm-language-server#configuration for more information.
[Info  - 14:48:57] A code lens resolve was requested for file:///c%3A/Users/karlp/elm-aws/src/LoadTest.elm
[Info  - 14:48:58] A code action was requested
[Info  - 14:48:58] Document Symbols were requested
[Info  - 14:48:58] Folding ranges were requested
[Info  - 14:48:58] Returned 8 folding ranges
[Info  - 14:48:58] A code lens was requested for file:///c%3A/Users/karlp/elm-aws/src/ElmUITest.elm
[Info  - 14:48:58] A code action was requested

Hey @Razzeee I got it working!

It works when I open the folder of my project, i.e. File -> Open Folder… from VS code. Then I see Elm in the Output window drop-down.

Formatting on save didn’t work at first, but I did see a message saying “Run npm install -g elm-format”. That didn’t work - what did was clearing the Elm Format Path setting that I had set earlier. Now it formats on save! And I have suggestions working too!

Thanks for the help.

It’s on the path, and I’m able to call it manually. Which is formatting the file successfully.