Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin executables are looked up via $PATH #157

Closed
alekstorm opened this issue Aug 7, 2014 · 6 comments
Closed

Plugin executables are looked up via $PATH #157

alekstorm opened this issue Aug 7, 2014 · 6 comments
Labels

Comments

@alekstorm
Copy link
Contributor

Currently, the terraform executable finds its plugin executables (e.g. terraform-provider-aws) via the PATH variable on *nix, which results in surprising behavior when the user is trying to run a terraform executable in a non-standard location. I think terraform should first look for the plugins next to it in its current directory before resorting to PATH.

@mattsoftware
Copy link

I disagree with this request. Let unix work the way unix does and if you prefer the executable to search the directory of terraform, then add that to the path and your good to go. No need to make the executable more complicated when all the necessary tools are already at your disposal.

export PATH=$(dirname $(which terraform)):$PATH

is all you need if you want to ensure that the dirrectory that terraform is in is searched first in your path. Or of course you can hardcode it in your .profile or wherever.

@alekstorm
Copy link
Contributor Author

I see your point - using both same-directory and $PATH lookup strategies would be even more confusing. Therefore, I think plugin executables should only be looked for in terraform's directory, and $PATH should not be consulted at all.

@mitchellh
Copy link
Contributor

Hm. We've been using the PATH then same directory approach for some time in Packer without issue (and Terraform inherits that codebase for plugins). But I think I agree with @alekstorm that we should look in the same directory first.

For reference:

path, err := exec.LookPath(path)

@mitchellh mitchellh added the bug label Aug 11, 2014
@c4milo
Copy link
Contributor

c4milo commented Aug 14, 2014

Is Terraform currently loading .terraformrc? I can't seem to find the code that invokes LoadConfig(path string)

@c4milo
Copy link
Contributor

c4milo commented Aug 14, 2014

FYI @mitchellh, I just ported packer code in terraform to load ~/.terraformrc. I will be sending a PR soon for you to review.

@mitchellh
Copy link
Contributor

Fixed. I also made it so that the directory and PATH are only looked up if the executable contains a path separator. This allows for absolute paths without wasting time.

@ghost ghost locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants