eugenn
eugenn

Reputation: 1647

Cannot compile chaincode

I am trying to compile the chaincode_example02 followed by this guide with Option 2 (for Mac). All steps were passed except compiling the code. I have the following error:

cd $GOPATH/src/github.com/chaincode_example02
go build
chaincode_example02.go:30:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of:
    /usr/local/Cellar/go/1.7.1/libexec/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)
    ($GOPATH not set)

Upvotes: 5

Views: 8150

Answers (4)

Rugved Mahamune
Rugved Mahamune

Reputation: 556

change the import statement to github.com/hyperledger/fabric-chaincode-go/shim and use "go get github.com/hyperledger/fabric-chaincode-go/shim"

Upvotes: 0

Nhan Cao
Nhan Cao

Reputation: 2515

You need to prepare the fabric source as libs follow command. Make sure GOPATH had been set first.

mkdir -p $GOPATH/src/github.com/hyperledger
cd $GOPATH/src/github.com/hyperledger
git clone -b release-1.2 https://github.com/hyperledger/fabric.git

Upvotes: 7

Clyde D'Cruz
Clyde D'Cruz

Reputation: 2065

As it says in the error message, your GOPATH environment variable is not set correctly.

Before doing a go build on the chaincode:

  1. Make sure your GOPATH is set up correctly

  2. Make sure you have the fabric code in your GOPATH

Upvotes: 1

Sergey Balashevich
Sergey Balashevich

Reputation: 2101

“Fabric” source code should be available locally in your GOPATH.

cd $GOPATH/src/github.com
mkdir hyperledger
cd hyperledger
git clone http://gerrit.hyperledger.org/r/fabric

Upvotes: 5

Related Questions