vscode-terraform
vscode-terraform copied to clipboard
Support pointing to path of terraform binary from settings.json
I use the chtf tool to install and switch between different versions of Terraform. Because of this when I start up vscode the output from terraform-ls shows.
* unable to find terraform: exec: "terraform": executable file not found in $PATH
* no terraform executor - unable to read version
* unknown terraform version - unable to find parser
* unknown terraform version - unable to find state storage
* cannot update schema as schema cache is not available
Pycharm and other JetBrains editors allow you to set the path to a terraform binary for plugin functionality. Would it be possible to add the option to point to a binary in /vscode/settings.json?
I couldn't find any documentation on this in either repository but if you're using https://github.com/hashicorp/terraform-ls you can update terraform.languageServer.args to add the --tf-exec argument after the serve command:

Since we can't update to 0.13 until we work around a removed feature I'm using this a fair amount.
Thanks @acdha that's done the trick for me 👍 .
Might be worth leaving the issue open until there's documentation since this is currently opaque
I use tfenv to manage my terraform installations.
I need to figure out how to point through that instead.
update: Looks like tfenv puts this in the standard path of /usr/local/bin/terraform so I pointed to that and it worked. Thanks for this! I've not had a functional terraform linter in months.
Might be worth leaving the issue open until there's documentation since this is currently opaque
@acdha Reopened
Nowadays we have this config in VSCode: terraform.languageServer.terraform.path
I've been using it for a while, before Terraform v1.3.9 it was working fine (no delay), but I'm starting to see delay again since I updated to v1.3.9