hashicorp / vscode-terraform

HashiCorp Terraform VSCode extension
https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform
Mozilla Public License 2.0
926 stars 179 forks source link

Unable to launch language server: Error: ENOENT: no such file or directory, stat '/root/.vscode-server/data/User/globalStorage/hashicorp.terraform/bin/terraform-ls' #1853

Open idkman23 opened 1 month ago

idkman23 commented 1 month ago

Extension Version

v2.19.0

VS Code Version

Version: 1.93.1 (Universal) Commit: 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40 Date: 2024-09-11T17:20:05.685Z (2 wks ago) Electron: 30.4.0 ElectronBuildId: 10073054 Chromium: 124.0.6367.243 Node.js: 20.15.1 V8: 12.4.254.20-electron.0 OS: Darwin x64 23.6.0

Operating System

14.6.1 (23G93)

Terraform Version

Terraform v1.3.9

Steps to Reproduce

use remote explorer extension to open us an SSH window inside a container

Expected Behavior

terraform extension is loaded

Actual Behavior

Unable to launch language server: Error: ENOENT: no such file or directory, stat '/root/.vscode-server/data/User/globalStorage/hashicorp.terraform/bin/terraform-ls'

Terraform Configuration

No response

Project Structure

No response

Gist

No response

Anything Else?

No response

Workarounds

No response

References

No response

Help Wanted

Community Note

jpogran commented 1 month ago

Hi @idkman23, thanks for reaching out. Extension v2.19.0 is around 2 years old at this point and there have been significant updates since then. I strongly recommend updating to the latest version, as it comes with significant performance improvements. Is there a reason you are using such an old version?

Towards this issue, that error usually happens using the WSL/SSH extension. I see you are on macOS, so I assume it's the Remote SSH Extension, but the same advice applies to the WSL extension. This usually happens form either not installing the Terraform extension 'locally' or it was unsuccessful. You can follow https://code.visualstudio.com/docs/remote/ssh#_managing-extensions for more information and some troubleshooting steps.

idkman23 commented 1 month ago

Hmm... I don't what's wrong with my vscode. On the host the extension version is v2.32.3 but when I try to install the extension when Remote SSHing inside the container, the extension version is v2.19.0. I've tried reinstalling on both the host and inside the container but with same results.

jpogran commented 1 month ago

So v2.19.0 is still when the extension downloaded terraform-ls from releases.hashicorp.com at runtime. In v2.20.0 we transitioned to bundling terraform-ls inside the extension. It is likely you aren't able to reach the internet inside the container to download terraform-ls, thus the path being empty. It's also possible the extension doesn't have permissions to write to /root/.vscode-server/data/User/globalStorage/hashicorp.terraform/bin, but that is unlikely.

I feel your pain in figuring out how to configure the Remote Extensions, especially the devcontainer one, they are not straightforward. I know you said you uninstalled/reinstalled, but with devcontainers there are two locations for the extension: local (your computer) and remote (the container/host/etc). Reinstalling will reinstall the local side, but not the remote side. Typically I have to rebuild the container in order for it to redeploy the extension to the remote side. You should see a .vscode-server/extensions and .vscode-server/data/User/globalStorage/hashicorp.terraform folders there.

Another thing to look at is that often devcontainers are customized with certain versions of tooling. It's possible the devcontainer may have something configured to use the older version.

Last thing I can think of is that there are several levels of settings. If you open the VS Code settings pane, there should be User. Workspace, Folder and Machine (if you have the devcontainer open). It's possible the devcontainer is providing something in the Machine config that is restricting the version.

idkman23 commented 1 month ago

@jpogran It kept defaulting to the 2.19.0. I deleted the ~/.vscode-server. Now I'm getting "Extension is not signed." message when installing the extension in a remote container. I am able to install other extensions.

saw this message in the logs every time I try to install the extension: [384041 ms] [16:04:07] [network] #24: https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery - error POST unable to get local issuer certificate