vscode-terraform icon indicating copy to clipboard operation
vscode-terraform copied to clipboard

Support pointing to path of terraform binary from settings.json

Open brodster2 opened this issue 5 years ago • 6 comments

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?

brodster2 avatar Aug 14 '20 13:08 brodster2

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.

acdha avatar Aug 21 '20 21:08 acdha

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

brodster2 avatar Aug 24 '20 13:08 brodster2

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

acdha avatar Aug 24 '20 17:08 acdha

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.

sheldonhull avatar Sep 01 '20 22:09 sheldonhull

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

@acdha Reopened

brodster2 avatar Sep 14 '20 09:09 brodster2

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

joelsdc avatar Mar 16 '23 01:03 joelsdc