VSCode: Terraform Module Calls not working

I have recently started to use VSCode on my Mac, Linux and Windows machines (due to the demise of Atom), and just had the opportunity to start using the HashiCorp Terraform plugin. It seems to me that most things are working, but when editing a “.tf” file in an initialized Terraform project directory, the “Terraform Module Calls” panel gives me an error:

The active editor cannot provide information about installed modules. Learn more about modules You may need to run ‘terraform get’ or update your language server version.

From command line, all of my regular terraform commands work fine, so I know the modules are initialized and current,

After reading through the Troubleshooting in the terraform-ls GitHub, I didn’t really find any advice on what the problem might be, but I did find the instructions on the Manual Migration of the plugin config in settings.json.

Also, it was unclear to me that the language server was actually installed somewhere, so I used brew install hashicorp/tap/terraform-ls. and it now exists in /usr/local/bin/terraform-ls, as does the Terraform executable itself. So I rewrite the Terraform config in settings.json like this:

    "terraform.codelens.referenceCount": true,

    "terraform.languageServer.enable": true,
    "terraform.languageServer.pathToBinary": "/usr/local/bin/terraform-ls",
    "terraform.languageServer.args": ["serve"],
    "terraform.languageServer.ignoreSingleFileWarning": false,

    "terraform.languageServer.terraform.path": "/usr/local/bin/terraform",
    "terraform.languageServer.terraform.timeout": "300",

Some of these are highlighted in a pale blue, like they aren’t recognized by the settings validation code, but I did not let that deter me.

When reloading, no errors are shown. The terraform-ls process is running (according to ps). But still, the error above is shown for Module Calls.

  • macOS Big Sur 11.6.1
  • Visual Studio Code 1.70.2
  • HashiCorp Terraform (plugin) v2.23.0
  • terraform-ls server (from Homebrew) v2.29.0

Thanks in advance,

Hi Jeff,
The new settings options are relevant for an upcoming version (2.24.0) we have only so far released as preview, not stable yet, which explains why some may be “greyed-out”.

As for the language server - you should not need to install it yourself, we bundle the LS binary appropriate for your system (macOS) with the extension. If you remove the mentioned settings, it should default to the bundled binary, which can also be verified from the log.

We have made some changes in the (planned) 0.24.0 / preview, one of which is that we no longer rely on installed modules only, but use that only as additional source - e.g. when linking to docs of the installed module version (since we cannot link to a version constraint).

We also moved the two panes under a dedicated section with Terraform icon:

Can you try disabling the existing stable version and installing the preview, to see if that resolves the issues?

If not, can you share the log with us, so we can take a closer look?


Thanks @radeksimko – I have installed the preview plugin and restarted VSCode, here’s what I get in the log:

2022-08-19T15:48:58.533-0400 [INFO]  Terraform version: 1.2.2
2022-08-19T15:48:58.534-0400 [DEBUG] using github.com/hashicorp/go-tfe v1.0.0
2022-08-19T15:48:58.534-0400 [DEBUG] using github.com/hashicorp/hcl/v2 v2.12.0
2022-08-19T15:48:58.534-0400 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2
2022-08-19T15:48:58.534-0400 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
2022-08-19T15:48:58.534-0400 [DEBUG] using github.com/zclconf/go-cty v1.10.0
2022-08-19T15:48:58.534-0400 [INFO]  Go runtime version: go1.18.1
2022-08-19T15:48:58.534-0400 [INFO]  CLI args: []string{"/usr/local/bin/terraform", "version", "-json"}
2022-08-19T15:48:58.534-0400 [TRACE] Stdout is not a terminal
2022-08-19T15:48:58.534-0400 [TRACE] Stderr is not a terminal
2022-08-19T15:48:58.534-0400 [TRACE] Stdin is not a terminal
2022-08-19T15:48:58.534-0400 [DEBUG] Attempting to open CLI config file: /Users/jeff/.terraformrc
2022-08-19T15:48:58.534-0400 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2022-08-19T15:48:58.535-0400 [DEBUG] Using modified User-Agent: HashiCorp Terraform/1.2.2 (+https://www.terraform.io) HashiCorp-terraform-exec/0.17.2
2022-08-19T15:48:58.535-0400 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2022-08-19T15:48:58.535-0400 [DEBUG] ignoring non-existing provider search directory /Users/jeff/.terraform.d/plugins
2022-08-19T15:48:58.535-0400 [DEBUG] ignoring non-existing provider search directory /Users/jeff/Library/Application Support/io.terraform/plugins
2022-08-19T15:48:58.535-0400 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2022-08-19T15:48:58.535-0400 [INFO]  CLI command args: []string{"version", "-json"}

I’m guessing all those “non-existing provider search directory” messages may have something to do with my issue? The new “Module Calls” panel gives the same error.

I allowed the installer to manually migrate settings and here’s what’s left:

    "terraform.codelens.referenceCount": true,
    "terraform.languageServer.path": "",
    "terraform.languageServer.terraform.logFilePath": "/tmp/htfp.log",

Hi Jeff,
The log I am interested in is the language server log, not the Terraform log, hence I linked to terraform-ls/TROUBLESHOOTING.md at main · hashicorp/terraform-ls · GitHub

terraform.languageServer.terraform.logFilePath refers to the latter and shouldn’t be needed at this point.

Users frequently confuse the two, although we tried to clarify that in the past in a few ways. I’d really welcome ideas how to reduce that confusion further! :smile: