Reputation: 2069
I'm doing this tutorial: https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html
Now I am on my Peer and want to Install & Instantiate Chaincode.
For this I am doing:
root@23096337731b:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/
But then I get this output:
2019-01-31 08:01:44.988 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-01-31 08:01:44.988 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: error getting chaincode code mycc: path to chaincode does not exist: /opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go
Update:
I think it's because I'm doing this:
peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/
And the compiler thinks that the github link is a local directory.
Upvotes: 2
Views: 4962
Reputation: 517
The key point is the place where you put the chaincode must be mounted exactly.
In the tutorial source code, when you read the file docker-compose-cli.yaml
, you will see this line
volumes
- ./../chaincode/:/opt/gopath/src/github.com/chaincode
./../chaincode
is the path to the chaincode folder
One more thing, if you choose golang for the chaincode, the path when you call install chaincode
will be shorter (read more):
# this installs the Go chaincode. For go chaincode -p takes the relative path from $GOPATH/src
peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/
Node.js version:
# this installs the Node.js chaincode
# make note of the -l flag to indicate "node" chaincode
# for node chaincode -p takes the absolute path to the node.js chaincode
peer chaincode install -n mycc -v 1.0 -l node -p /opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/
Upvotes: 4
Reputation: 263
First you need to check if the chaincode is on that folder. Also the path for a go chaincode has to be relative to the gopath.
Upvotes: 1