Cosmos-sdk: Build fails in Go 1.10.3, 1.10.4 and 1.11

Created on 7 Sep 2018  ·  45Comments  ·  Source: cosmos/cosmos-sdk

Summary of Bug

I believe this is from the Ledger dependency:

vendor/github.com/brejski/hid/hid_darwin.go:162: cannot use nil as type _Ctype_CFAllocatorRef in argument to _Cfunc_CFStringCreateWithBytes
vendor/github.com/brejski/hid/hid_darwin.go:216: cannot use nil as type _Ctype_CFDictionaryRef in argument to func literal

Steps to Reproduce


Run make when using Go 1.10.4 or 1.11. Works with 1.10.1

I did not test 1.10.2 and 1.10.3


For Admin Use

  • [ ] Not duplicate issue
  • [ ] Appropriate labels applied
  • [ ] Appropriate contributors tagged
  • [ ] Contributor assigned/self-assigned

Most helpful comment

On a brand-new install, after a successful make get_vendor_deps.

$ go version
go version go1.11 darwin/amd64

$ make install
go install -tags "netgo ledger" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=416181be" ./cmd/gaia/cmd/gaiad
# github.com/cosmos/cosmos-sdk/vendor/github.com/brejski/hid
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
# github.com/cosmos/cosmos-sdk/vendor/github.com/brejski/hid
vendor/github.com/brejski/hid/hid_darwin.go:162:41: cannot use nil as type _Ctype_CFAllocatorRef in argument to _Cfunc_CFStringCreateWithBytes
vendor/github.com/brejski/hid/hid_darwin.go:216:149: cannot use nil as type _Ctype_CFDictionaryRef in argument to func literal

Maybe related?

_edit_: thanks to @xla I can get it built:

$ env CGO_ENABLED=0 make install
go install -tags "netgo ledger" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=416181be" ./cmd/gaia/cmd/gaiad
go install -tags "netgo ledger" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=416181be" ./cmd/gaia/cmd/gaiacli

All 45 comments

It also works with 1.10.3

I failed too.

go version go1.10.3 linux/amd64

make install
go install -tags "netgo ledger" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=416181be" ./cmd/gaia/cmd/gaiad

github.com/cosmos/cosmos-sdk/store

store/iavlstore.go:43:8: undefined: iavl.VersionedTree
Makefile:61: recipe for target 'install' failed
make: * [install] Error 2

go test -v iavlstore_test.go

command-line-arguments

./iavlstore_test.go:32:41: undefined: iavl.VersionedTree
./iavlstore_test.go:32:61: undefined: CommitID
./iavlstore_test.go:33:10: undefined: iavl.NewVersionedTree
./iavlstore_test.go:44:15: undefined: CommitID
./iavlstore_test.go:50:15: undefined: newIAVLStore
./iavlstore_test.go:75:15: undefined: newIAVLStore
./iavlstore_test.go:148:15: undefined: newIAVLStore
./iavlstore_test.go:207:15: undefined: newIAVLStore
./iavlstore_test.go:263:24: undefined: iavlStore
./iavlstore_test.go:325:10: undefined: iavl.NewVersionedTree
./iavlstore_test.go:325:10: too many errors
FAIL command-line-arguments [build failed]

@flyq I believe you need to update your vendor dependencies.

/cc @zmanian

I think we just need to update our dependency for brejski/hid.

If you update
https://github.com/ZondaX/ledger-goclient to master from v0.1

Are folks only having problems on MacOS or linux/windows as well?

Should we pull packages living under ZondaX into the Tendermint org? I think we will have to maintain them

vendor/github.com/ZondaX/hid-go/hid_darwin.go:216: cannot use 0 (type int) as type *_Ctype_struct___CFDictionary in argument to func literal

that's with the latest update to master as suggested by @zmanian. Notice its the same line but different error as Sunny.

using:
go version go1.10.3 darwin/amd64

passes once upgraded to 1.11 for me

^ ditto. works now for me

Closing due to fix

Still running into this issue on 1.10.3...

```cosmos-sdk [develop] :> rm -rf build/ vendor/
cosmos-sdk [develop] :> make get_vendor_deps
--> Generating vendor directory via dep ensure
(1/55) Wrote github.com/pelletier/[email protected]
(2/55) Wrote github.com/pkg/[email protected]
(3/55) Wrote github.com/tendermint/[email protected]
(4/55) Wrote github.com/prometheus/common@master
(5/55) Wrote github.com/syndtr/goleveldb@master
(6/55) Wrote github.com/zondax/[email protected]
(7/55) Wrote github.com/tendermint/[email protected]
(8/55) Wrote github.com/tendermint/[email protected]
(9/55) Wrote gopkg.in/[email protected]
(10/55) Wrote github.com/stretchr/[email protected]
(11/55) Wrote github.com/prometheus/client_model@master
(12/55) Wrote github.com/pmezard/[email protected]
(13/55) Wrote github.com/tendermint/ed25519@master
(14/55) Wrote github.com/prometheus/client_golang@ae27198cdd90bf12cd134ad79d1366a6cf49f632
(15/55) Wrote github.com/prometheus/procfs@master
(16/55) Wrote github.com/davecgh/[email protected]
(17/55) Wrote github.com/ebuchman/fail-test@95f809107225be108efcf10a3509e4ea6ceef3c4
(18/55) Wrote github.com/rcrowley/go-metrics@e2704e165165ec55d062f5919b4b29494e9fa790
(19/55) Wrote github.com/btcsuite/btcutil@d4cc87b860166d00d6b5b9e0d3b3d71d6088d4d4
(20/55) Wrote github.com/spf13/[email protected]
(21/55) Wrote github.com/ZondaX/hid-go@master
(22/55) Wrote github.com/fsnotify/[email protected]
(23/55) Wrote github.com/gorilla/[email protected]
(24/55) Wrote github.com/gogo/[email protected]
(25/55) Wrote github.com/tendermint/[email protected]
(26/55) Wrote github.com/hashicorp/hcl@master
(27/55) Wrote github.com/bartekn/go-bip39@a05967ea095d81c8fe4833776774cfaff8e5036c
(28/55) Wrote github.com/spf13/[email protected]
(29/55) Wrote github.com/inconshreveable/[email protected]
(30/55) Wrote golang.org/x/sys@master
(31/55) Wrote github.com/gorilla/[email protected]
(32/55) Wrote github.com/beorn7/perks@master
(33/55) Wrote github.com/golang/snappy@master
(34/55) Wrote github.com/gorilla/[email protected]
(35/55) Wrote golang.org/x/crypto@master
(36/55) Wrote github.com/bgentry/[email protected]
(37/55) Wrote github.com/spf13/[email protected]
(38/55) Wrote github.com/matttproud/[email protected]
(39/55) Wrote github.com/mattn/[email protected]
(40/55) Wrote google.golang.org/genproto@master
(41/55) Wrote github.com/spf13/jwalterweatherman@master
(42/55) Wrote google.golang.org/[email protected]
(43/55) Wrote github.com/mitchellh/[email protected]
(44/55) Wrote github.com/jmhodges/levigo@master
(45/55) Wrote github.com/spf13/[email protected]
(46/55) Wrote golang.org/x/net@292b43bbf7cb8d35ddf40f8d5100ef3837cced3f
(47/55) Wrote github.com/spf13/[email protected]
(48/55) Wrote golang.org/x/[email protected]
(49/55) Wrote github.com/go-logfmt/[email protected]
(50/55) Wrote github.com/magiconair/[email protected]
(51/55) Wrote github.com/kr/logfmt@master
(52/55) Wrote github.com/go-stack/[email protected]
(53/55) Wrote github.com/btcsuite/btcd@master
(54/55) Wrote github.com/go-kit/[email protected]
(55/55) Wrote github.com/golang/[email protected]
cosmos-sdk [develop] :> make install
go install -tags "netgo ledger" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=e13cdc02" ./cmd/gaia/cmd/gaiad

github.com/cosmos/cosmos-sdk/vendor/github.com/ZondaX/hid-go

vendor/github.com/ZondaX/hid-go/hid_darwin.go:216: cannot use 0 (type int) as type _Ctype_struct___CFDictionary in argument to func literal
make: *
* [install] Error 2
cosmos-sdk [develop] :> git rev-parse HEAD
e13cdc02606eb32d23fe94e05590b4e6914201d4
```

latest develop still passes for me (with newest deps), I'm running go version go1.11 darwin/amd64

Able to replicate. I had to upgrade to go1.11 per @rigelrozanski suggestion.

ya, i got the exact same error on 1.10.3 and 1.11 did the trick

fails for me with go version go1.11 darwin/amd64

@RomanBrodetski can you update your vendor dependencies?

After running make get_vendor_deps it works, thanks!

I know go modules aren't supported yet, but thought I'd put this here. Getting similar errors on go1.11 darwin/amd64:

[email protected]/store/iavlstore.go:43:8: undefined: iavl.VersionedTree

@shanev you need to update you vendor dependencies: make get_vendor_deps

@alexanderbez I'm using go modules introduced in go 1.11. It downloads modules to $GOPATH/pkg/mod which isn't in GOPATH/src, so dep ensure can't run.

I see. I dont know if we have plans on supporting or using modules yet.

It seems like the migration path to modules is to have a known good Gopkg.lock file for go1.11 and then run go mod init

https://github.com/golang/go/wiki/Modules#how-to-define-a-module

Getting similar errors on go1.11 darwin/amd64

running make get_vendor_deps and them compiling still results in the same error.

On a brand-new install, after a successful make get_vendor_deps.

$ go version
go version go1.11 darwin/amd64

$ make install
go install -tags "netgo ledger" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=416181be" ./cmd/gaia/cmd/gaiad
# github.com/cosmos/cosmos-sdk/vendor/github.com/brejski/hid
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
# github.com/cosmos/cosmos-sdk/vendor/github.com/brejski/hid
vendor/github.com/brejski/hid/hid_darwin.go:162:41: cannot use nil as type _Ctype_CFAllocatorRef in argument to _Cfunc_CFStringCreateWithBytes
vendor/github.com/brejski/hid/hid_darwin.go:216:149: cannot use nil as type _Ctype_CFDictionaryRef in argument to func literal

Maybe related?

_edit_: thanks to @xla I can get it built:

$ env CGO_ENABLED=0 make install
go install -tags "netgo ledger" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=416181be" ./cmd/gaia/cmd/gaiad
go install -tags "netgo ledger" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=416181be" ./cmd/gaia/cmd/gaiacli

I had the same issue. @adrianbrink

➜  cosmos-sdk git:(master) ✗  go version
go version go1.11 darwin/amd64
➜  cosmos-sdk git:(master) ✗ make install
go install -tags "netgo ledger" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=416181be" ./cmd/gaia/cmd/gaiad
# github.com/cosmos-sdk/vendor/github.com/brejski/hid
vendor/github.com/brejski/hid/hid_darwin.go:162:41: cannot use nil as type _Ctype_CFAllocatorRef in argument to _Cfunc_CFStringCreateWithBytes
vendor/github.com/brejski/hid/hid_darwin.go:216:149: cannot use nil as type _Ctype_CFDictionaryRef in argument to func literal
make: *** [install] Error 2

image

@mabodx please update the vendor deps. iirc, github.com/brejski/hid isn't used anymore.

@alexanderbez Right now master is 416181be60f32750178c24be52c9ebf15ce9a25b, which lists github.com/brejski/hid in Gopkg.lock:

[[projects]]
  branch = "master"
  digest = "1:70f6b224a59b2fa453debffa85c77f71063d8754b90c8c4fbad5794e2c382b0f"
  name = "github.com/brejski/hid"
  packages = ["."]
  pruneopts = "UT"
  revision = "06112dcfcc50a7e0e4fd06e17f9791e788fdaafc"

It's a transitive dependency of github.com/zondax/ledger-goclient, imported by crypto/ledger.go.

So 48b08affede2cea076a3cf13b2e3f72ed262b743 is the latest from github.com/brejski/hid

if you aren't getting it from make get_vendor_deps, it's mostly likely that your dep is old. make update_tools will upgrade your dep and then make get_vendor_deps should get the correct hid verison.

@zmanian Because cosmos/cosmos-sdk has checked in a Gopkg.lock file, dep won't pick a version of any dependency (direct or transitive) for me, it will use the specific revision that's recorded in that file. "The correct hid version" is the one that's listed there: 06112dc, not 48b08af.

To get me to use the latest rev 48b08af, a maintainer needs to re-run dep ensure, maybe via dep ensure -update github.com/brejski/hid, commit the resulting Gopkg.lock to master, and push that change.

Okay. I am asking for consensus on doing a v0.24.3 release to update the Gopkg.toml

Using a vendored copy of Cosmos SDK.

Gopkg.toml:

[[constraint]]
  name = "github.com/cosmos/cosmos-sdk"
  branch = "develop"

go version go1.11 darwin/amd64

Dep seems to resolve an older version of tendermint/iavl for some reason.

# github.com/.../vendor/github.com/cosmos/cosmos-sdk/store/iavlstore.go:43:8: undefined: iavl.MutableTree
# github.com/.../vendor/github.com/tendermint/iavl
github.com/tendermint/iavl/proof_range.go:295:6: lastDepth declared but not used
vet: typecheck failures

For anyone else having issues with vendored use, try this Gopkg.toml:

[[constraint]]
  name = "github.com/cosmos/cosmos-sdk"
  branch = "develop"

[[override]]
  name = "github.com/tendermint/iavl"
  version = "=v0.11.0"

[[override]]
  name = "github.com/tendermint/tendermint"
  version = "=v0.23.1-rc0"

Works for https://github.com/cosmos/cosmos-sdk/commit/1e26ba2e0e9c1e0457383ff302a97396c227cddb.

@shanev I've experienced similar issues with using the SDK...as an SDK. Hoping with 0.25 many of these dependency issues will be resolved. Thanks!

similar issues...

~/go/src/github.com/cosmos/cosmos-sdk$ make install
go install -tags "netgo ledger" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=416181be" ./cmd/gaia/cmd/gaiad
# github.com/cosmos/cosmos-sdk/vendor/github.com/brejski/hid
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
# github.com/cosmos/cosmos-sdk/vendor/github.com/brejski/hid
vendor/github.com/brejski/hid/hid_darwin.go:162:41: cannot use nil as type _Ctype_CFAllocatorRef in argument to _Cfunc_CFStringCreateWithBytes
vendor/github.com/brejski/hid/hid_darwin.go:216:149: cannot use nil as type _Ctype_CFDictionaryRef in argument to func literal
make: *** [install] Error 2

works without package lock

As a quick fix, try

env CGO_ENABLED=0 make install
go version
go version go1.10.3 darwin/amd64

I create a new project using cosmos-sdk-cli
Then I go to the directory, and run make, It fails

$ make
go get github.com/golang/dep/cmd/dep
go build -o bin/th_projectcli cmd/th_projectcli/main.go && go build -o bin/th_projectd cmd/th_projectd/main.go
# th_project/vendor/github.com/cosmos/cosmos-sdk/store
vendor/github.com/cosmos/cosmos-sdk/store/iavlstore.go:43:8: undefined: iavl.VersionedTree
make: *** [build] Error 2

@adrianbrink

You need go1.11 to build the SDK at this point.

You need go1.11 to build the SDK at this point.

upgrade to 1.11.1

same error

go version go1.11.1 darwin/amd64

This works for me.

go version
go version go1.11.1 darwin/amd64

git checkout master
dep ensure -update github.com/brejski/hid
make get_vendor_deps
make install

This works for me.

go version
go version go1.11.1 darwin/amd64

git checkout master
dep ensure -update github.com/brejski/hid
make get_vendor_deps
make install

Did you make the gaiad and gaiacli ?
I got the error in a new project created by cosmos-sdk-cli .

yeah make install builds gaiad and gaiacli puts them in your PATH.

Here's an update using the latest develop branch, with Cosmos in vendor/.

Gopkg.toml:

[[constraint]]
  name = "github.com/cosmos/cosmos-sdk"
  branch = "develop"

dep ensure, then try to build my app.

Fun error:

vendor/github.com/cosmos/cosmos-sdk/types/context.go:167:32: undefined: "github.com/..../vendor/github.com/tendermint/tendermint/abci/types".VoteInfo
vendor/github.com/cosmos/cosmos-sdk/types/context.go:168:41: undefined: "github.com/..../vendor/github.com/tendermint/tendermint/abci/types".VoteInfo
vendor/github.com/cosmos/cosmos-sdk/types/context.go:192:11: newHeader.ProposerAddress undefined (type "github.com/..../vendor/github.com/tendermint/tendermint/abci/types".Header has no field or method ProposerAddress)
vendor/github.com/cosmos/cosmos-sdk/types/context.go:216:44: undefined: "github.com/..../vendor/github.com/tendermint/tendermint/abci/types".VoteInfo

For some reason, just including Cosmos as a dependency does not pick up the right versions of dependencies. Tendermint is v0.23.1, and IAVL is v0.8.1.

@shanev yes, unfortunately you'll need overrides. See an example here 👍

go version go1.11.1 darwin/amd64

thank you! this line fixed my install error

dep ensure -update github.com/brejski/hid

go version go1.11.1 darwin/amd64

We are now successfully building with Go 1.11.4. Hence closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cwgoes picture cwgoes  ·  3Comments

rigelrozanski picture rigelrozanski  ·  3Comments

ValarDragon picture ValarDragon  ·  3Comments

fedekunze picture fedekunze  ·  3Comments

jackzampolin picture jackzampolin  ·  3Comments