TL;DR; Go to ---- EDIT section below
I am using hfc@0.6.5 in a standalone node.js application.
A membersrvc and peer are started with docker-compose, where:
membersrvc: container_name: membersrvc image: hyperledger/fabric-membersrvc:latest ports: - "7054:7054" command: membersrvc vp0: container_name: peer image: hyperledger/fabric-peer:latest ports: - "7050:7050" - "7051:7051" - "7053:7053" environment: - CORE_PEER_ADDRESSAUTODETECT=true - CORE_VM_ENDPOINT=unix:///var/run/docker.sock - CORE_LOGGING_LEVEL=DEBUG - CORE_PEER_ID=vp0 - CORE_SECURITY_ENABLED=true - CORE_PEER_PKI_ECA_PADDR=172.17.0.2:7054 - CORE_PEER_PKI_TCA_PADDR=172.17.0.2:7054 - CORE_PEER_PKI_TLSCA_PADDR=172.17.0.2:7054 - CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=noops [...] links: - membersrvc command: sh -c "sleep 10; peer node start" The node.js application successfully registers new users and tries to deploy a chaincode using the enrolledUser.deploy(deployRequest); method.
As a value of deployRequest.chaincodePath a path'github.com/asset-chaincode/' is set.The directory contains a chaincode .go file.
A callback of deployTx.on('complete', cb) prints its log message:
SUCCESS: Successfully deployed chaincode [chainCodeId:415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58], deploy request={"fcn":"init","args":[],"confidential":true,"metadata":{"type":"Buffer","data":[48,...155,253,0]},"chaincodePath":"github.com/gvlax/chaincodes/asset-chaincode"}, response={"uuid":"415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58","chaincodeID":"415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58"} chaincodeId=415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58 However, when I check an output of a peer console, I can see error messages
--> full logs here:
peer | 15:40:00.416 [dockercontroller] deployImage -> ERRO 47a Error building images: The command '/bin/sh -c go install build-chaincode && cp src/build-chaincode/vendor/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin && mv $GOPATH/bin/build-chaincode $GOPATH/bin/23991376d1b935790631a448843fd12a9d60f7ab3f0b8b55f629cf0190077436' returned a non-zero code: 1 [...] peer | ---> Running in 812439684bf7 peer | src/build-chaincode/asset-chaincode.go:25:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of: peer | /opt/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT) peer | /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOPATH) peer | src/build-chaincode/asset-chaincode.go:26:2: cannot find package "github.com/hyperledger/fabric/core/crypto/primitives" in any of: peer | /opt/go/src/github.com/hyperledger/fabric/core/crypto/primitives (from $GOROOT) peer | /opt/gopath/src/github.com/hyperledger/fabric/core/crypto/primitives (from $GOPATH) peer | package build-chaincode peer | imports github.com/hyperledger/fabric/vendor/github.com/op/go-logging: must be imported as github.com/op/go-logging [...] It looks like there are some issues not exactly related to the chaincode compilation on the peer. Or the chaincode is deployed to a location on the peer where relative import paths in the chaincode cannot be resolved ....
---- EDIT (some hours later)
After many attempts and experiments, I think my problem is always the same:
Regardless of any valid chaincode (stored locally in a directory $GOPATH/src/gibhub.com/<mychaincode_dir> + building with no errors) after being deployed on a peer with the method enrolledUser.deploy(deployRequest) (hfc@0.6.5), a result gives always the same errors on the target node:
peer | Step 4 : RUN go install build-chaincode && cp src/build-chaincode/vendor/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin && mv $GOPATH/bin/build-chaincode $GOPATH/bin/0881d0fe8f4528e1369bfe917cd207d919a07758cc098e212ca74f6766c636d4 peer | ---> Running in b0ca2abbe609 peer | src/build-chaincode/asset-chaincode.go:25:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of: peer | /opt/gopath/src/build-chaincode/vendor/github.com/hyperledger/fabric/core/chaincode/shim (vendor tree) peer | /opt/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT) The imports of the cc the peer complains about are:
import ( "encoding/base64" "errors" "fmt" "github.com/hyperledger/fabric/core/chaincode/shim" [...] moreover, when I go to the peer CLI, the shim can be found there ...
$ docker exec -it peer bash $ find / -name shim /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim $ echo $GOPATH/ /opt/gopath/ Isn't something wrong with the fabric-peer image ???