Can not get elm-analyse and elm-language-server work

I have a project with the code from Elm’s tutorial.
Page itself works great, elm-format also works well. But elm-language-server and elm-analyse fails with same error:

`--> elm-analyse src/Main.elm
Fetching package information from package.elm-lang.org.
Fetched dependencies
INFO: Started...
INFO: No configuration provided. Using default configuration.
INFO: Load dependency elm/browser 1.0.1
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '/home/ildar/Projects/learning-elm/test/elm-stuff/packages/elm/browser/1.0.1/elm.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.getDependencyFiles (/home/ildar/.config/yarn/global/node_modules/elm-analyse/dist/app/util/file-gatherer.js:63:26)
    at Array.<anonymous> (/home/ildar/.config/yarn/global/node_modules/elm-analyse/dist/app/ports/dependency-files.js:13:35)
    at Function.f (/home/ildar/.config/yarn/global/node_modules/elm-analyse/dist/app/backend-elm.js:2170:19)
    at A3 (/home/ildar/.config/yarn/global/node_modules/elm-analyse/dist/app/backend-elm.js:59:28)
    at Object.b (/home/ildar/.config/yarn/global/node_modules/elm-analyse/dist/app/backend-elm.js:1974:7)
    at _Scheduler_step (/home/ildar/.config/yarn/global/node_modules/elm-analyse/dist/app/backend-elm.js:1818:20)

As I figured out all modules located in local cache inside ~/elm directory. How I can make elm-analyse and elm-language-server load modules form local cache?

Environment:
installed globally with yarn

  • elm@0.19.0-no-deps
  • @elm-tooling/elm-language-server@1.4.1
  • elm-analyse@0.16.4
  • elm-format@0.8.2
    installed with system package manager
  • node v10.16.3

I think this turned out to bo a problem with elm-analyse? https://github.com/elm-tooling/elm-language-server/issues/176

Here is my bug report against elm-analyse.

I looked through the file-gather.ts and did not saw any mention of a local cache. It tries to load modules only from the project/elm-stuff/ directory.

Can you try if you hit the same problem with the vscode extension? https://marketplace.visualstudio.com/items?itemName=Elmtooling.elm-ls-vscode

I do not really know how to use the VSCode, I installed extension over VSCode and still have no auto-completion and syntax check. All tools: elm-analyse, elm-test, elm-format, elm-language-server and elm itself accessible with the PATH environment variable.

VSCode installed from flathub. JavaScript and Python extensions from Mircrosof works well.

This should outline all you need to do

Please also make sure that you have a valid elm.json that actually points to your .elm files

Got it work. I should use “File->Open Folder” instead of “File->Open File”.

I wrote one example from the elm tutorial and auto-completions still works.
Same code with the nvim makes the language server fail.

Great you got it to work by changing working directory.

I think it might be improved in the future with better error messages or search for elm.json could be recursive upwards the directory structure (probably error prone by itself).

Yes the VSCode plugin works. But console elm-analyse and elm-language-server with language-server-neovim still doesn’t.

Also elm-analyse outputs There is no elm.json file in this directory. elm-analyse will only work in directories where such a file is located. if I call it from non project directory.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.