-
Notifications
You must be signed in to change notification settings - Fork 602
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
cannot find package "github.com/hashicorp/hcl/v2" #371
Comments
Hi @lvrfrc87! It looks like you are using Go in "GOPATH mode", which is a legacy mode that doesn't understand Go Modules and therefore can't install HCL v2. HCL 2 was published after Go Modules was introduced, so it can be automatically installed only in Go Modules mode. (For more information, see our Version Selection wiki page.) If you aren't able to use Modules mode then you may be able to get this to work with some additional manual steps, using the minimal module compatibility mechanisms. I must admit I'm a bit rusty on how exactly that works but I think the following steps should allow you to use HCL v2 in a codebase that isn't yet using modules mode:
That step five is the one I'm not totally sure about. My understanding/memory is that in minimal compatibility mode Go will accept that the packages within HCL refer to each other as |
Hi @apparentlymart, |
If you aren't working in a legacy codebase that needs to keep using |
FYI I ran into this issue while trying to install a Terraform binary using The problem command was a simple For anyone else who might run into this, I discovered that you can work around by setting the env var # works
GO111MODULE=on go get github.com/terraform-linters/tflint I'm not sure if this is the right way to solve the problem though, I haven't been around Go modules for long enough to know if this is just standard practice. |
Hi @lsegal,
I think with recent versions of Go modules mode ought to be activated by default for |
The thing is I was not running this inside my GOPATH.
|
Sorry, I don't really understand what you mean here. Any documentation you can link? I am using Fedora 31 with go version 1.13.10. I have my gopath set in my zshrc as such:
When I try to do:
I get same as @lsegal 's paste. What do I need to do to have this working properly? I was able to get it to work using @apparentlymart 's workaround, but I'd like to use whatever is the proper way to handle this instead of applying workarounds. Thanks guys! |
in your homedir: GO111MODULE=on go get -u github.com/aiven/terraform-provider-aiven ...or whichever package you want. This is on a system with GOPATH set to ~/go. You will then find the binary in ~/go/bin/. thanks @lsegal , great tip. |
go clean --modcache |
I am no longer having issues with newer golang versions 1.18+. Seems they made it much more streamlined insofar as setting up dev envs and such. Thanks for all the help! <3 |
Hi all! I'm sorry things have continued to be confusing here, but I'm glad to hear that recent Go toolchain updates have helped. At this point GOPATH mode has been obsolete for several Go toolchain versions and so I believe the expectation is that if you are using modern Go that you don't set We aren't equipped to offer general advice on using the Go toolchain in this repository, and it seems like the original request was solved, so I'm going to close this issue. If anyone runs into similar problems later I think it would be better to ask about them in general Go discussion forums rather than here, because what we've been discussing is a general situation with Go modules and not something specific to HCL. Thanks! |
I am trying to write a provide following the tutorial on link.[https://www.terraform.io/docs/extend/writing-custom-providers.html]
When I try to do
go get github.com/hashicorp/terraform-plugin-sdk/plugin
I have the below error:I then tried
go get github.com/hashicorp/hcl/v2
but I have pretty much the same error.The text was updated successfully, but these errors were encountered: