Launching language server: c:\Users\SunnyNazar.vscode\extensions\hashicorp.terraform-2.0.1/lsp/terraform-ls serve
[Error - 9:00:32 PM] Starting client failed
Error: spawn EBUSY
at ChildProcess.spawn (internal/child_process.js:394:11)
at Object.spawn (child_process.js:553:9)
at c:\Users\SunnyNazar.vscode\extensions\hashicorp.terraform-2.0.1\node_modules\vscode-languageclient\lib\main.js:354:40
Could you please check.
I don't run on Windows myself, but the error code suggests this may happen when a file is overwritten when being used by the system. This would likely never happen if the server was installed automatically on VSCode launch, as the server never starts before it's installed/upgraded, but this could happen on manual enabling/disabling I assume and we should probably address that.
Either way I believe this something to be addressed on the VSCode side, so I'm going to transfer the issue there.
Mine fails to start as well, but with a different error message. It says Error for "initialize" (ID 0): [-32098] Workspace not initialized. Please run 'terraform init' in c:\..... But the main folder for my code base doesn't contain any Terraform code. The Terraform is all in subfolders. If the main folder when opening VS Code contains Terraform code then it works, but it's bogus to assume that every code base will have Terraform code in its root folder.
To work around this flaw, I added a dummy.tf file to my root folder. It has an azurerm provider block and nothing else. That works. I also tried a dummy.tf file with a local variable declaration and for some reason that wasn't good enough.
Others on my team have this same problem. The extension is quite busted now. :confounded:
There's a bunch of other tickets for this problem : terraform-ls the "stable" language server needs a .terraform folder with provider plugins in to start ; in your root folder.
terraform-lsp, the "unstable" one doesn't.
I've got a local fork of terraform-lsp because I've been fixing some of it's panic bugs that cause it to crash, so I just build it and set
"terraform.languageServer": {
"pathToBinary": "/path/to/built/terraform-lsp",
"external": true,
},
And ~everything works~. (except when it crashes, which is less now I've patched about four nil pointer panics out of it.) It's not perfect (doc links are broken and it still doesn't properly do terraform_remote_state resources) but it works and has more features than the Hashicorp LSP.
Nearly everything works ; formatting was moved into the terraform-ls server and I don't think terraform-lsp does it. Support for executing terraform fmt has been removed.
NB : the Hashicorp LSP is on a more solid footing and actually has unit tests. It just seems to be rather young in comparison.
I'm experiencing the same issue. The root folder of the workspace does not have the terraform code, so the server blows up. And since pinning to a previous version of the plugin is also broken, this plugin is now completely useless.
UX wise this error is really annoying. Because it switches focus to terraform output (on same panel as terminal) so every time I open new project, load window etc. this panel steals focus from terminal.
Confirming on extension version v2.0.1 on VSCode Version: 1.46.0
Launching language server: /Users/walther/.vscode/extensions/hashicorp.terraform-2.0.1/lsp/terraform-ls serve
... snip ...
[Error - 4:59:51 PM] Server initialization failed.
Message: Workspace not initialized. Please run `terraform init` in /Users/walther/git/[redacted]
Thankful for all the good work in the extension whenever I'm working on Terraform, and would appreciate the extension staying quiet when I'm working on something else
The initialization error messaging has been softened and focus hijacking addressed. Some features also now don't require an initialized root module. The most recent version of the LS also will do some discovery of additional root module locations in some scenarios and we are adding override capability in #423.
Going to close this in favor of some of the other issues open for more specific features/bugs. The best tracking issue on the LS side for various directory/module configurations is hashicorp/terraform-ls#32.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the context necessary to investigate further.
Most helpful comment
Mine fails to start as well, but with a different error message. It says
Error for "initialize" (ID 0): [-32098] Workspace not initialized. Please run 'terraform init' in c:\..... But the main folder for my code base doesn't contain any Terraform code. The Terraform is all in subfolders. If the main folder when opening VS Code contains Terraform code then it works, but it's bogus to assume that every code base will have Terraform code in its root folder.To work around this flaw, I added a
dummy.tffile to my root folder. It has an azurerm provider block and nothing else. That works. I also tried adummy.tffile with a local variable declaration and for some reason that wasn't good enough.Others on my team have this same problem. The extension is quite busted now. :confounded: