# Terraform vscode extension with WSL2

**URL:** <https://discuss.hashicorp.com/t/terraform-vscode-extension-with-wsl2/37938>\
**Category:** Terraform Editor Integrations\
**Created:** [April 3, 2022, 11:16pm UTC](https://discuss.hashicorp.com/t/terraform-vscode-extension-with-wsl2/37938 "2022-04-03T23:16:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmed1smael](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ahmed1smael/32/27200_2.png) [@ahmed1smael](https://discuss.hashicorp.com/u/ahmed1smael)\
**Post date:** [April 3, 2022, 11:16pm UTC](https://discuss.hashicorp.com/t/terraform-vscode-extension-with-wsl2/37938/1 "2022-04-03T23:16:07Z")

</div>

Hi All,

I am running vscode in windows on remote WSL2. I have installed HashiCorp Terraform extension, however I started getting the errors in the screenshot attached and the extension doesn’t seem to be working when I open terraform files. I have v1.0.1 installed. Does anyone know what’s going on here? Thanks!

 ![image](https://global.discourse-cdn.com/hashicorp/original/3X/5/1/517c6c70967258f5cc4e45a92e75cacef8bd3b69.png)

---

<div class="post-metadata">

**Author:** ![radeksimko](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/radeksimko/32/47475_2.png) [@radeksimko](https://discuss.hashicorp.com/u/radeksimko)\
**Post date:** [April 4, 2022, 7:12am UTC](https://discuss.hashicorp.com/t/terraform-vscode-extension-with-wsl2/37938/2 "2022-04-04T07:12:24Z")

</div>

Hi @ahmed1smael  
Do you mind sharing how exactly did you open the path in VS Code?

AFAICT the message you shared above would occur if you were to access the UNC path from a _Windows_ shell, e.g. by running `code "\\wsl$\Ubuntu-20.04\home\example"` from _Windows_.

The recommended way is to open the shell of the Linux distro you’re using (e.g. Ubuntu) _then_ open VS Code with the Linux path from there, such as `code /home/example` . This starts the VSCode editor in Windows as a ‘client’ with the WSL VSCode Server ‘inside’ the WSL distro. As explained in the [WSL tutorial](https://code.visualstudio.com/docs/remote/wsl-tutorial#_run-in-wsl):

> VS Code is installing a small server on the Linux side that the desktop VS Code will then talk to. That server will then install and host extensions in WSL, so that they run in the context of the tools and frameworks installed in WSL. In other words, your language extensions will run against the tools and frameworks installed in WSL, not against what is installed on the Windows side, as it should for the proper development experience.

We plan to improve the error message as part of [Better guide WSL users opening UNC `\\wsl$\` paths · Issue #656 · hashicorp/terraform-ls · GitHub](https://github.com/hashicorp/terraform-ls/issues/656)

---

<div class="post-metadata">

**Author:** ![ahmed1smael](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ahmed1smael/32/27200_2.png) [@ahmed1smael](https://discuss.hashicorp.com/u/ahmed1smael)\
**Post date:** [April 5, 2022, 11:41pm UTC](https://discuss.hashicorp.com/t/terraform-vscode-extension-with-wsl2/37938/3 "2022-04-05T23:41:42Z")

</div>

Thanks @radeksimko , I opened vscode from inside wsl and I made sure the the lower left coroner shows I am connected to WSL:  
 ![image](https://global.discourse-cdn.com/hashicorp/original/3X/0/5/05c50a0fdce455c097682ba500d7e56bb2cf414c.png)

however now I am getting the following error message:  
 ![image](https://global.discourse-cdn.com/hashicorp/original/3X/4/9/49596a43ef120beee5dd13eed46d7a2bbab1f28a.png)

Just to mention that I am opening an entire directory that contains multiple sub-dirs and different file types, not just terraform.

Thanks

---

<div class="post-metadata">

**Author:** ![ahmed1smael](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ahmed1smael/32/27200_2.png) [@ahmed1smael](https://discuss.hashicorp.com/u/ahmed1smael)\
**Post date:** [April 5, 2022, 11:47pm UTC](https://discuss.hashicorp.com/t/terraform-vscode-extension-with-wsl2/37938/4 "2022-04-05T23:47:09Z")

</div>

ah nvm, I went to the extension section on vscode and a new button `install for WSL` showed up next to the terraform extension, clicking and reloading vscode solved the problem.

Thanks again.

---

<div class="post-metadata">

**Author:** ![radeksimko](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/radeksimko/32/47475_2.png) [@radeksimko](https://discuss.hashicorp.com/u/radeksimko)\
**Post date:** [April 6, 2022, 6:45pm UTC](https://discuss.hashicorp.com/t/terraform-vscode-extension-with-wsl2/37938/5 "2022-04-06T18:45:46Z")

</div>

With regards to the other error you shared (“Editing a single file is not yet supported”) - We’re [actively working](https://github.com/hashicorp/terraform-ls/pull/843) on introducing a limited support for editing single files, but still recommend (and will continue recommending) opening whole folders instead.

For example, if you use a terminal to open VS Code, you’d run `code /path/to/folder` instead of `code /path/to/folder/main.tf`, or similarly you would drag a whole folder into VS Code GUI instead of a single file.
