hashicorp / vscode-terraform

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

Support pointing to path of terraform binary from settings.json #456

Open brodster2 opened 4 years ago

brodster2 commented 4 years ago

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?

acdha commented 4 years ago

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:

Screen Shot 2020-08-21 at 5 11 21 PM

Since we can't update to 0.13 until we work around a removed feature I'm using this a fair amount.

brodster2 commented 4 years ago

Thanks @acdha that's done the trick for me 👍 .

acdha commented 4 years ago

Might be worth leaving the issue open until there's documentation since this is currently opaque

sheldonhull commented 4 years ago

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.

brodster2 commented 4 years ago

Might be worth leaving the issue open until there's documentation since this is currently opaque

@acdha Reopened

joelsdc commented 1 year ago

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