Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hyperledger Fabric: peer chaincode instantiate error

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.

like image 406
jworthington Avatar asked Mar 07 '23 19:03

jworthington


2 Answers

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.
like image 62
Mohamed Youssef Avatar answered May 16 '23 07:05

Mohamed Youssef


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.

like image 45
aatk Avatar answered May 16 '23 06:05

aatk