0

I have started a fabric network with three orgs one pear for each org and one orderer. Created one channel and added the peers to the channel.But when i try to install the chaincode it says directory not found. I also mounted the volume inside my cli config. i am entering cli bash before entering the command also checked using peer channel list command to see if my peer is joined in a channel.

my cli config

        - /var/run/:/host/var/run/
        - ./../chaincode/:/opt/gopath/fabric-samples/food-network/chaincode
        - ./crypto-config:/opt/gopath/fabric-samples/food-network/crypto-config/

my peer command

 peer chaincode install -n chain  chain -v 1.0

error


Error: open /opt/gopath/fabric-samples/food-network/chaincode/chain: no such file or directory

my chain code is named chain.go. Its a go file and it has been built.

also when i try this command:


peer chaincode install -n chain -p chain -v 1.0

it gives this error:


 error getting chaincode code chain: path to chaincode does not exist: /opt/gopath/src/chain
sh1515
  • 47
  • 9

1 Answers1

1

In order to install chaincode, you need to build a chaincode package. You can either run

peer chaincode package ...

followed by

peer chaincode install ...

or you can use the -p option with peer chaincode install to package and install together.

When using the peer cli to package chaincode, it will look for your Go chaincode under $GOPATH/src. The cli container has its GOPATH set to /opt/gopath.

I'm not sure where your actual chaincode is located, but assuming your your Go code is located in ./../chaincode on your host, you would need to change your volume mount to

- ./../chaincode/:/opt/gopath/src/chaincode

and then you can run

peer chaincode install -n chain -p chaincode -v 1.0
Gari Singh
  • 11,418
  • 2
  • 18
  • 41
  • i installed the chaincode after changing the directory but when i try to initiate the chaincode with this command `eer chaincode instantiate -o orderer.food-network.com:7050 -C channelshovon -n chain -v 0 -c '{"Args":[""]}' -P "OR ('ImporterMSP.member')" ` it gives error and when i check the logs it gives this error `cannot get package for chaincode (chain:0)-err:open /var/hyperledger/production/chaincodes/chain.0: no such file or directory ` – sh1515 Nov 03 '19 at 09:59
  • when i check the peer for installed chain code it shows that chain v0 is installed – sh1515 Nov 03 '19 at 10:01