4

Error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package ../../bin/github.com/hyperledger/fabric/chaincode/marbles: open /bin/github.com/hyperledger/fabric/chaincode/marbles: no such file or directory.

I see it is looking for a relative directory. relative to what? chaincode install was fine. If the chaincode is installed, why can it not be found for instantiate? 1 peer. 1 solo orderer. channel joined fine.

0xsegfault
  • 2,899
  • 6
  • 28
  • 58
jworthington
  • 723
  • 1
  • 9
  • 17

2 Answers2

5

Chaincode install doesn't mean you have correctly mapped your chaincode path,

peer chaincode install -p {path} -n {} -v {}

Chaincode instantiate builds and instantiate your chaincode.

peer chaincode instantiate -n {} -v {} -c {} -C {}
  • In docker compose file double check the volumes/chaincode mapping of the cli.
  • Use actual path when installing chaincode.
  • I installed from the directory the chaincode is in. i.e. -p ./ Attempting to reinstall yields the correct error of already exists. Chaincode.0 file exists in /var/hyperledger/production/chaincodes. Not using docker. I know it said OK on install and I believe it said 0 block received or something like that. – jworthington Oct 18 '17 at 20:57
  • Ah. So the chaincode path must be something like github.com/hyperledger/fabric/chaincode/ccname which is relative to gopath somehow. Full path is /usr/local/go/src/github.com/hyperledger/fabric/chaincode/ccname. $GOPATH is /usr/local/go/bin. $GOROOT is /usr/local/go. So fabric expects chaincode in $GOROOT/src/? Seems odd but works. thx – jworthington Oct 18 '17 at 21:43
  • @MohamedYoussef sorry for hijacking the question in advance. I'm using the NodeJS SDK and I'm getting an ok on install and a fail on instantiate. Could you have a look at this question: https://stackoverflow.com/questions/50963477/hyperledger-fabric-cant-find-go-files-when-building-chaincode? – Byebye Jun 25 '18 at 13:54
2

There's a "hidden" expectation in the path mapping. It expects there to be a /src directory under gopath that caused me some trouble until I figured it out.

Here's my solution fwiw:

In your compose yaml for the peer you would set the env variable :

- GOPATH=/opt/gopath

Then in the CLI you can install and instantiate thus:

SIGNED_CHAINCODE_LOCATION=/opt/gopath/src/chaincode/<cc_dir>/<signed_cc>.out

peer chaincode install /${SIGNED_CHAINCODE_LOCATION} 

And instantiate as normal. Just use the directory instead of the .out file if you don't need to package and sign.

In my case I added a working dir in the peer that set the chain code to a relative directory to my base blockchain directory: - ./chaincode/:/opt/gopath/src/chaincode/ and dumped the go folder into there.

aatk
  • 160
  • 1
  • 7