terracost
terracost copied to clipboard
Cannot install terracost with go 1.18
Steps to Reproduce:
- Using
go version
:go version go1.18.1 darwin/arm64
-
Run:
go install github.com/cycloidio/terracost@latest
: -
Install fails with error message:
go: github.com/cycloidio/terracost@latest (in github.com/cycloidio/[email protected]): The go.mod file for the module providing named packages contains one or more replace directives. It must not contain directives that would cause it to be interpreted differently than if it were the main module.
-
go.mod
file contains:
replace github.com/hashicorp/terraform => github.com/hashicorp/terraform v0.15.3
Expected result:
Installation of terracost
should work on Go >= 1.16
GO111MODULE=off
Workaround fails on missing hashicorp/terraform/configs
:
- Force using
GOPATH
install behavior with:-
export GO111MODULE=off; go get github.com/cycloidio/terracost
-
Returns error message:
cannot find package "github.com/hashicorp/terraform/configs" in any of: /opt/homebrew/Cellar/go/1.18.1/libexec/src/github.com/hashicorp/terraform/configs (from $GOROOT) /Users/exampleuser/src/pub/go/src/github.com/hashicorp/terraform/configs (from $GOPATH)
-
- Similar issues when trying to forcibly install
terraform
+ dependencies toGOPATH
viago get
:-
export GO111MODULE=off; go get
-
Returns more errors:
export GO111MODULE=off; go get github.com/hashicorp/terraform cannot find package "github.com/vmihailenco/msgpack/v4" in any of: /opt/homebrew/Cellar/go/1.18.1/libexec/src/github.com/vmihailenco/msgpack/v4 (from $GOROOT) /Users/exampleuser/src/pub/go/src/github.com/vmihailenco/msgpack/v4 (from $GOPATH) cannot find package "github.com/vmihailenco/msgpack/v4/codes" in any of: /opt/homebrew/Cellar/go/1.18.1/libexec/src/github.com/vmihailenco/msgpack/v4/codes (from $GOROOT) /Users/exampleuser/src/pub/go/src/github.com/vmihailenco/msgpack/v4/codes (from $GOPATH) cannot find package "go.etcd.io/etcd/clientv3" in any of: /opt/homebrew/Cellar/go/1.18.1/libexec/src/go.etcd.io/etcd/clientv3 (from $GOROOT) /Users/exampleuser/src/pub/go/src/go.etcd.io/etcd/clientv3 (from $GOPATH) cannot find package "go.etcd.io/etcd/clientv3/concurrency" in any of: /opt/homebrew/Cellar/go/1.18.1/libexec/src/go.etcd.io/etcd/clientv3/concurrency (from $GOROOT) /Users/exampleuser/src/pub/go/src/go.etcd.io/etcd/clientv3/concurrency (from $GOPATH) cannot find package "go.etcd.io/etcd/pkg/transport" in any of: /opt/homebrew/Cellar/go/1.18.1/libexec/src/go.etcd.io/etcd/pkg/transport (from $GOROOT) /Users/exampleuser/src/pub/go/src/go.etcd.io/etcd/pkg/transport (from $GOPATH) cannot find package "github.com/hashicorp/hcl/hcl/ast" in any of: /opt/homebrew/Cellar/go/1.18.1/libexec/src/github.com/hashicorp/hcl/hcl/ast (from $GOROOT) /Users/exampleuser/src/pub/go/src/github.com/hashicorp/hcl/hcl/ast (from $GOPATH) cannot find package "github.com/hashicorp/hcl/hcl/parser" in any of: /opt/homebrew/Cellar/go/1.18.1/libexec/src/github.com/hashicorp/hcl/hcl/parser (from $GOROOT) /Users/exampleuser/src/pub/go/src/github.com/hashicorp/hcl/hcl/parser (from $GOPATH) cannot find package "github.com/hashicorp/hcl/hcl/token" in any of: /opt/homebrew/Cellar/go/1.18.1/libexec/src/github.com/hashicorp/hcl/hcl/token (from $GOROOT) /Users/exampleuser/src/pub/go/src/github.com/hashicorp/hcl/hcl/token (from $GOPATH)
-
Could you confirm https://github.com/cycloidio/terracost/pull/75/ is fixing your problem?
I am not super-familiar with golang, so not sure if I am doing something wrong, but I seem to have the same problem:
$ go get github.com/cycloidio/terracost@ff0b0053
go: go.mod file not found in current directory or any parent directory.
'go get' is no longer supported outside a module.
To build and install a command, use 'go install' with a version,
like 'go install example.com/cmd@latest'
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
$ go install github.com/cycloidio/terracost@ff0b0053
go: downloading github.com/cycloidio/terracost v0.5.1-0.20220513154206-ff0b0053cde6
go: downloading github.com/spf13/afero v1.6.0
go: downloading github.com/hashicorp/hcl/v2 v2.10.1
go: downloading github.com/machinebox/progress v0.2.0
go: downloading google.golang.org/api v0.60.0
go: downloading github.com/mitchellh/mapstructure v1.4.2
go: downloading golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9
go: downloading golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871
go: downloading golang.org/x/mod v0.5.1
go: downloading golang.org/x/sys v0.0.0-20211124211545-fe61309f8881
go: downloading google.golang.org/grpc v1.42.0
go: downloading google.golang.org/protobuf v1.27.1
package github.com/cycloidio/terracost is not a main package
$ go version
go version go1.19.3 linux/amd64