minamijoyo / tfupdate

Update version constraints in your Terraform configurations
MIT License
537 stars 23 forks source link

Initial installation failure #5

Closed yermulnik closed 4 years ago

yermulnik commented 4 years ago
> go get -v github.com/minamijoyo/tfupdate
github.com/minamijoyo/tfupdate (download)
github.com/hashicorp/logutils (download)
github.com/google/go-github (download)
github.com/google/go-querystring (download)
github.com/hashicorp/hcl (download)
package github.com/hashicorp/hcl/v2: cannot find package "github.com/hashicorp/hcl/v2" in any of:
        /usr/local/go/src/github.com/hashicorp/hcl/v2 (from $GOROOT)
        /home/yz/go/src/github.com/hashicorp/hcl/v2 (from $GOPATH)
package github.com/hashicorp/hcl/v2/hclsyntax: cannot find package "github.com/hashicorp/hcl/v2/hcls
yntax" in any of:
        /usr/local/go/src/github.com/hashicorp/hcl/v2/hclsyntax (from $GOROOT)
        /home/yz/go/src/github.com/hashicorp/hcl/v2/hclsyntax (from $GOPATH)
package github.com/hashicorp/hcl/v2/hclwrite: cannot find package "github.com/hashicorp/hcl/v2/hclwr
ite" in any of:
        /usr/local/go/src/github.com/hashicorp/hcl/v2/hclwrite (from $GOROOT)
        /home/yz/go/src/github.com/hashicorp/hcl/v2/hclwrite (from $GOPATH)
github.com/zclconf/go-cty (download)
github.com/mitchellh/cli (download)
github.com/armon/go-radix (download)
github.com/bgentry/speakeasy (download)
github.com/posener/complete (download)
github.com/hashicorp/go-multierror (download)
github.com/hashicorp/errwrap (download)

> go version
go version go1.13.1 linux/amd64

Anything I'm missing?

minamijoyo commented 4 years ago

@yermulnik Thank you for reporting the problem.

It seems to have failed to get github.com/hashicorp/hcl/v2 I'm not sure go get fails if the dependent library is v2 module. Can you try the following?

$ git clone https://github.com/minamijoyo/tfupdate
$ cd tfupdate/
$ make install
$ tfupdate --version
yermulnik commented 4 years ago

Makefile approach worked:

> tfupdate --version
0.3.0

Thanks. Though I think need to amend/fix straight go get … approach.

minamijoyo commented 4 years ago

Thank you for checknig it.

When I had started writing the code, the hcl2 library had been in hashicorp/hcl2 repository, and afterward it moved to the hcl2 branch in the hashicorp/hcl.

https://github.com/hashicorp/hcl2/issues/115

The hcl2 branch has not been merged into master yet, but released as v2.0.0 tag.

https://github.com/hashicorp/hcl/releases/tag/v2.0.0

So I switched the dependency from hashicorp/hcl2@master to hashicorp/hcl@hcl2.

https://github.com/minamijoyo/tfupdate/commit/e2161f596eba69e70388263a8cfca43b1e8805f8

The Go module treats v2 tag as special meanings.

https://blog.golang.org/v2-go-modules

The master branch in hashicorp/hcl has go.mod, but it is a v1 module.

https://github.com/hashicorp/hcl/blob/914dc3f8dd7c463188c73fc47e9ced82a6e421ca/go.mod

So, If my understanding is correct, I think this problem will be resolved when the hcl2 branch in hashicorp/hcl is merged into master. I don't know if this is a go get issue or a specification.

Maybe related to this? https://github.com/golang/go/issues/35630

As a workaround, we should check out the code before building. We will probably need to fix the instruction in README.

Please let me know if my understanding is wrong. Thanks!

yermulnik commented 4 years ago

Thanks for clarifications. My own issue was already fixed with Makefile approach =)

minamijoyo commented 4 years ago

@yermulnik I've fixed the instruction in README. #6 Thank you for reporting this!