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

Elm-language-server in vscode not working for not finding elm version #231

Open
n-doronzo opened this issue Feb 11, 2022 · 11 comments
Open

Comments

@n-doronzo
Copy link

First, I'd like to thank you for providing such a good tool for such a great language.

Expected Behavior

To start without errors and work when opening the project

Current Behavior

It does not work.
It used to work, and suddenly stopped.

Possible Solution

Steps to Reproduce (for bugs)

Just by opening the workspace in vscode.

Context

The "output" tab for elm displays the following:
immagine
I tried my self running elm --version on a terminal window both inside and outside the project and it prints the version correctly (0.19.1).
Here is the elm.json for my project
immagine
I tried disabling and re-enabling the tool, also uninstalling and reinstalling. Nothing changed...

Your Environment

  • Version used: elm-tooling 2.4.1, elm 0.19.1
  • Editor used: vscode
  • Environment name and version (e.g. node.js 5.4): node 14.17.0
  • Operating System and version: windows 11

Thanks in advance

@razzeee
Copy link
Member

razzeee commented Feb 11, 2022

How did you install elm and how did you configure the commandline/terminal in vscode. It's usually a combination of that. The terminal in vscode can have different intitialization (missing bin folder etc) then your normal one.

@n-doronzo
Copy link
Author

To install elm I used the elm installer for windows. I also tried to re-install elm itself, but it didn't have any effect. About vscode what configurations in particular are you talking about? I haven't touched almost anything after installing vscode

@razzeee
Copy link
Member

razzeee commented Feb 11, 2022

I just realized those probably don't matter, the cases where I've seen those problems where with task.json, but this doesn't touch tasks at all.

You could try to downgrade the vscode plugin, to see if that changes anything, as you mentioned it stopped working. I've pushed an update last weekend.

@razzeee razzeee transferred this issue from elm-tooling/elm-language-server Feb 11, 2022
@SpadeAceman
Copy link

I also had this same experience today - suddenly, this extension's features were no longer working for any Elm files. Closing and reopening VSCode multiple times did not fix the problem.

My eventual solution was to disable and re-enable this extension after restarting VSCode, which (so far) seems to have fixed the problem.

I was upgraded to version 2.4.1 a few days ago, but this extension was working fine for a while after that. Similarly, I was upgraded to the latest version of VSCode recently, but again Elm files were working fine for a while after that.

I did notice that re-enabling this extension took nearly 2 seconds:

image

Subsequent testing shows extension startup times exceeding 2 seconds.

Additionally, I went looking thru Output -> Log (Extension Host) to find messages related to this extension, and here's what I found:

[2022-02-14 23:26:44.264] [exthost] [info] Extension host with pid 21560 started
...
[2022-02-14 23:26:53.972] [exthost] [info] Not activating extension 'elmTooling.elm-ls-vscode': Timed out while searching for 'workspaceContains' pattern **/elm.json

... (eventually, I disabled and re-enabled the extension) ...

[2022-02-14 23:43:07.857] [exthost] [info] ExtensionService#_doActivateExtension elmTooling.elm-ls-vscode, startup: false, activationEvent: 'workspaceContains:**/elm.json'
[2022-02-14 23:43:35.498] [exthost] [warning] elmTooling.elm-ls-vscode - Code actions of kind 'quickfix 'requested but returned code action is of kind 'refactor.extract'. Code action will be dropped. Please check 'CodeActionContext.only' to only return requested code actions.

Note that this extension failed on initial VSCode launch, after it waited almost 10 seconds.

I realize the log screenshot from @n-doronzo didn't indicate timeout issues, so this may not be the same bug. But it was definitely the same end-user experience (it was working, then it suddenly stopped working for no obvious reason).

Your Environment

  • Version used: elm-tooling 2.4.1, elm 0.19.1
  • Editor used: VSCode 1.64.2
  • Operating System and version: Windows 10 (20H2)

@razzeee
Copy link
Member

razzeee commented Feb 15, 2022

How deep/big is the folder your trying to run this on, the timeout seems to stem from the search for the .elm file(s)

@SpadeAceman
Copy link

I'm only getting started with Elm, so I have very few .elm files. This computer has a modern SSD.

Below is an illustration of the number of directories in my development path - the elm.json file is right there in the workspace folder, so I'd think workspaceContains:**/elm.json ought to find it right away.

C:\Users\userid\f1\f2\f3\dev  <-- workspace folder
C:\Users\userid\f1\f2\f3\dev\elm.json
C:\Users\userid\f1\f2\f3\dev\elm-stuff
C:\Users\userid\f1\f2\f3\dev\src  <-- Elm source code files here

@razzeee
Copy link
Member

razzeee commented Feb 15, 2022

It does not stop, after finding one, as we need to find all possible elm.json files. Still, I guess you don't have any other package managers creating folders in that directory.

@sayid-sh
Copy link

sayid-sh commented Jun 18, 2022

I'm new to elm. everything worked for past week but now stopped working. installed elm with Elm windows installer.
vscode output for Elm:

[Info - 6:48:40 PM] Loading Elm tree-sitter syntax from c:\Users\saeed.vscode\extensions\elmtooling.elm-ls-vscode-2.4.1\server\out\tree-sitter-elm.wasm
[Info - 6:48:50 PM] Found 1 elm.json files for workspace d:/elm-workshop-0.19/Intro/part3
[Info - 6:48:50 PM] Found 1 unique elmWorkspaces for workspace d:/elm-workshop-0.19/Intro/part3
[Info - 6:48:50 PM] Starting language server for folder: file:///d%3A/elm-workshop-0.19/Intro/part3
[Warn - 6:48:51 PM] {"shortMessage":"Command failed with exit code 1: elm --version","command":"elm --version","escapedCommand":"elm --version","exitCode":1,"stdout":"","stderr":"","failed":true,"timedOut":false,"isCanceled":false,"killed":false}
[Warn - 6:48:51 PM] Could not figure out elm version, this will impact how good the server works.
Error: Command failed with exit code 1: elm --version
at makeError (c:\Users\saeed.vscode\extensions\elmtooling.elm-ls-vscode-2.4.1\server\node_modules\execa\lib\error.js:60:11)
at Function.module.exports.sync (c:\Users\saeed.vscode\extensions\elmtooling.elm-ls-vscode-2.4.1\server\node_modules\execa\index.js:194:17)
at execCmdSync (c:\Users\saeed.vscode\extensions\elmtooling.elm-ls-vscode-2.4.1\server\out\compiler\utils\elmUtils.js:45:32)
at Object.getElmVersion (c:\Users\saeed.vscode\extensions\elmtooling.elm-ls-vscode-2.4.1\server\out\compiler\utils\elmUtils.js:119:20)
at Program. (c:\Users\saeed.vscode\extensions\elmtooling.elm-ls-vscode-2.4.1\server\out\compiler\program.js:173:36)
at Generator.next ()
at fulfilled (c:\Users\saeed.vscode\extensions\elmtooling.elm-ls-vscode-2.4.1\server\out\compiler\program.js:24:58)
[Info - 6:48:51 PM] Reading elm.json from d:/elm-workshop-0.19/Intro/part3/elm.json
[Warn - 6:48:52 PM] {"shortMessage":"Command failed with exit code 1: elm make","command":"elm make","escapedCommand":"elm make","exitCode":1,"stdout":"","stderr":"","failed":true,"timedOut":false,"isCanceled":false,"killed":false}
[Error - 6:48:52 PM] Error parsing files for d:/elm-workshop-0.19/Intro/part3/elm.json:
Error: ENOENT: no such file or directory, open 'C:\Users\saeed\AppData\Roaming\elm\undefined\packages\elm\browser\1.0.2\elm.json'
[Error - 6:48:52 PM] Notification handler 'textDocument/didOpen' failed with message: Cannot read properties of undefined (reading 'getTree')
[Error - 6:48:52 PM] Request textDocument/documentSymbol failed.
Message: Request textDocument/documentSymbol failed with message: Cannot read properties of undefined (reading 'getTree')
Code: -32603
[Error - 6:48:52 PM] Request textDocument/foldingRange failed.
Message: Request textDocument/foldingRange failed with message: Cannot read properties of undefined (reading 'getTree')
Code: -32603
[Error - 6:48:52 PM] TypeError: Cannot read properties of undefined (reading 'getTree') delayed processing of request
[Error - 6:48:59 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Cannot read properties of undefined (reading 'getTree')
Code: -32603
[Error - 6:48:59 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Cannot read properties of undefined (reading 'getTree')
Code: -32603
[Error - 6:49:02 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Cannot read properties of undefined (reading 'getTree')
Code: -32603
[Error - 6:49:02 PM] Request textDocument/codeAction failed.
Message: Request textDocument/codeAction failed with message: Cannot read properties of undefined (reading 'getTree')
Code: -32603
[Error - 6:49:04 PM] Request textDocument/codeAction failed.
Message: Request textDocument/codeAction failed with message: Cannot read properties of undefined (reading 'getTree')
Code: -32603
[Error - 6:49:04 PM] Request textDocument/completion failed.
Message: Request textDocument/completion failed with message: Cannot read properties of undefined (reading 'getTree')
Code: -32603
[Error - 6:49:46 PM] Request textDocument/hover failed.
Message: Request textDocument/hover failed with message: Cannot read properties of undefined (reading 'getTree')
Code: -32603

i tried disable and enable the extension. deleting elm-stuff, deleting elm.json and creating with "elm init" again. none of them worked. in the output, i noticed there is an undefined in the path which should be 0.19.1.
'C:\Users\saeed\AppData\Roaming\elm*undefined*\packages\elm\browser\1.0.2\elm.json'

elm.json file contents :

{
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/browser": "1.0.2",
"elm/core": "1.0.0",
"elm/html": "1.0.0"
},
"indirect": {
"elm/json": "1.0.0",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.3"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}

@razzeee
Copy link
Member

razzeee commented Jun 19, 2022

i tried disable and enable the extension. deleting elm-stuff, deleting elm.json and creating with "elm init" again. none of them worked. in the output, i noticed there is an undefined in the path which should be 0.19.1.

We're running elm --version to determine the version, so we probabably aren't able to find the elm executable anymore

@sayid-sh
Copy link

Thanks for reply. elm --version works fine in terminal. If you create a new folder and run elm init in it then create a simple hello world program in src directory everything works fine. then you can copy your elm files into this new folder and start installing elm packages you need again. and everything works. but sometimes after a command elm install the problem occurs again. and you should do these process again, which is frustrating. it seems elm install sometimes messes with elm.json file. I don't know maybe changes the order of packages or puts "\n" character code which is different in linux and windows. I decided to try my luck on a linux machine now.

@chemacortes
Copy link

chemacortes commented Jun 20, 2022

There are two ways to open vscode in windows:

  1. "%LOCALAPPDATA%\Programs\Microsoft VS Code\bin\code.cmd" (node command script)
  2. "%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe" (electron app)

Try the second one.

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

No branches or pull requests

5 participants