获取链代码的错误mycc:链代码的路径不存在

问题描述 投票:0回答:2

我正在做这个教程:https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html

现在我在我的同行,并希望安装和实例化Chaincode。

为此,我正在做:

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/

但后来我得到了这个输出:

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

更新:

我想这是因为我这样做:

peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/

编译器认为github链接是本地目录。

hyperledger-fabric hyperledger
2个回答
0
投票

首先,您需要检查链代码是否在该文件夹上。 go chaincode的路径也必须与gopath相关。


0
投票

关键点是你必须准确安装链码的地方。

在教程源代码中,当您读取文件docker-compose-cli.yaml时,您将看到此行

volumes
    - ./../chaincode/:/opt/gopath/src/github.com/chaincode

./../chaincode是chaincode文件夹的路径

还有一件事,如果你为链码选择golang,你调用install chaincode时的路径会更短(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版本:

# 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/
© www.soinside.com 2019 - 2024. All rights reserved.