elixir-tools / elixir-tools.vscode

Visual Studio Code extension for Elixir
https://marketplace.visualstudio.com/items?itemName=elixir-tools.elixir-tools
Other
87 stars 9 forks source link

Client is not running and can't be stopped #61

Closed crbelaus closed 9 months ago

crbelaus commented 9 months ago

I am having trouble getting NextLS to start from VSCode. I always get the following message in the "Extension host" output tab.

2023-10-04 08:19:32.954 [error] Error: Client is not running and can't be stopped. It's current state is: starting
    at _.shutdown (/Users/crbelaus/.vscode/extensions/elixir-tools.elixir-tools-0.10.1/dist/extension.js:2:96701)
    at _.stop (/Users/crbelaus/.vscode/extensions/elixir-tools.elixir-tools-0.10.1/dist/extension.js:2:96282)
    at _.stop (/Users/crbelaus/.vscode/extensions/elixir-tools.elixir-tools-0.10.1/dist/extension.js:2:258296)
    at e.deactivate (/Users/crbelaus/.vscode/extensions/elixir-tools.elixir-tools-0.10.1/dist/extension.js:2:433218)
    at n.Z (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:9460)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:7585
    at Array.map (<anonymous>)
    at n.S (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:7572)
    at n.terminate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:118:7844)
    at o.terminate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:122:1513)
    at D (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:135:9800)
    at MessagePortMain.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:135:6225)
    at MessagePortMain.emit (node:events:513:28)
    at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367)

I can run the nextls executable manually and start it on port 9000 as explained in the README:

➜  ~ ~/.cache/elixir-tools/nextls/bin/nextls --port 9000
Starting on port 9000

Then, I can switch the VSCode configuration to use the TCP adapter and port 9000 but it still seems not to do anything. I can't see the .elixir_tools directory and the language server functionality does not work.

mhanberg commented 9 months ago

Just to clarify the procedure, you need to switch the settings to tcp, quit vscode, start the server, then re-open vscode

mhanberg commented 9 months ago

What version of next-ls?

crbelaus commented 9 months ago

Just to clarify the procedure, you need to switch the settings to tcp, quit vscode, start the server, then re-open vscode

Yeah, this is the process I am following.

How can I check the next-ls version? I've cleaned everything up and downloaded the extension again so I think it fetched the latest next-ls version.

mhanberg commented 9 months ago

path/to/nextls --version

crbelaus commented 9 months ago

Hmm it seems to not like it:

➜  ~ ~/.cache/elixir-tools/nextls/bin/nextls --version

07:55:35.436 [notice] Application next_ls exited: NextLS.Application.start(:normal, []) returned an error: shutdown: failed to start child: NextLS.LSPSupervisor
    ** (EXIT) an exception was raised:
        ** (NextLS.LSPSupervisor.OptionsError) Unknown Options: --version

Valid options:

--stdio              Starts the server using stdio
--port port-number   Starts the server using TCP on the given port

            (next_ls 0.9.1) lib/next_ls/lsp_supervisor.ex:51: NextLS.LSPSupervisor.init/1
            (stdlib 5.0.2) supervisor.erl:330: :supervisor.init/1
            (stdlib 5.0.2) gen_server.erl:962: :gen_server.init_it/2
            (stdlib 5.0.2) gen_server.erl:917: :gen_server.init_it/6
            (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Kernel pid terminated (application_controller) ({application_start_failure,next_ls,{{shutdown,{failed_to_start_child,'Elixir.NextLS.LSPSupervisor',{#{message => <<"Unknown Options: --version \n\nValid options:\n\n--stdio              Starts the server using stdio\n--port port-number   Starts the server using TCP on the given port\n">>,'__struct__' => 'Elixir.NextLS.LSPSupervisor.OptionsError','__exception__' => true},[{'Elixir.NextLS.LSPSupervisor',init,1,[{file,"lib/next_ls/lsp_supervisor.ex"},{line,51}]},{supervisor,init,1,[{file,"supervisor.erl"},{line,330}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,962}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,917}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]}}},{'Elixir.NextLS.Application',start,[normal,[]]}}})

Crash dump is being written to: erl_crash.dump...done
mhanberg commented 9 months ago

Then that means your version is wildly out of date

crbelaus commented 9 months ago

Oh wow. That was right. I don't know how I managed to have such an old version...

Thanks for the help @mhanberg, it is working now. I just removed the ~/.cache/elixir-tools/nextls/bin/nextls file, closed VSCode and reopened it again. It prompted me for permissions to download NextLS and got the latest version as expected.

mhanberg commented 9 months ago

Excellent, sorry about that!