dsfe167834
2018-03-29 15:40 阅读 339

在$ GOROOT或$ GOPATH中找不到软件包CID

I am trying to customize tuna-app chaincode of the tuna-app example. I want to use cid package inside my chaincode to make ABAC decisions about who is allowed to run the chaincode. When I try to install chaincode, I get the following error:

Error: Error getting chaincode code chaincode: 
Error getting chaincode package bytes: Error obtaining dependencies for github.com/hyperledger/fabric/core/chaincode/lib/cid: 
<go, [list -f {{ join .Deps "
"}} github.com/hyperledger/fabric/core/chaincode/lib/cid]>: failed with error: "exit status 1" 
cannot load package: package github.com/hyperledger/fabric/core/chaincode/lib/cid: cannot find package "github.com/hyperledger/fabric/core/chaincode/lib/cid" in any of:
/opt/go/src/github.com/hyperledger/fabric/core/chaincode/lib/cid (from $GOROOT)
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/lib/cid (from $GOPATH)

I am usind Docker to run peer, orderer, ca, and cli containers. The Docker image which is used to build chaincode is hyperledger/fabric-ccenv. This image is created using Dockerfile; the interesting line I found was:

ADD payload/goshim.tar.bz2 $GOPATH/src/

which adds the tar.bz2 inside the $GOPATH/src folder (I believe). The .tar.bz2 file contains all Go packages used by chaincode. I tried to insert the cid package and to create a new .tar.bz2 file with the package inside. Then I rebuilt the image. The image now contains the cid package, but I still get the same error.

Why is it still missing the package?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    dongzhe3573 dongzhe3573 2018-04-03 09:17

    In the startFabric.sh from your tuna-app, you launch the cli container using:

    docker-compose -f ./docker-compose.yml up -d cli
    

    Have a look at the mounting declaration of the persistent volumes in your compose yaml file. You should see something like this because the tuna-app is based on fabcar from the fabric-samples:

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

    If you see this declaration, copy in your local machine the folder /hyperledger/fabric/core/chaincode/lib/cid into your chaincode folder. You should find it in chaincode/abac if you are using the last version of fabric samples (https://github.com/hyperledger/fabric-samples).

    点赞 评论 复制链接分享
  • douyun3887 douyun3887 2018-03-29 20:04

    I think you should not create a new goshim.tar.bz2. If you think it is easier make sure cid is in the correct path within the archive, e.g. github.com/hyperledger/fabric/core/chaincode/lib/cid

    To test this you can make a debug output:

    ADD payload/goshim.tar.bz2 $GOPATH/src/
    RUN ls $GOPATH/src/github.com/hyperledger/fabric/core/chaincode/lib/cid
    

    I would recommend to download cid within the Dockerfile:

    RUN go get -d github.com/hyperledger/fabric/core/chaincode/lib/cid
    
    点赞 评论 复制链接分享

相关推荐