Error deploying chaincode in Hyperledger Fabric 2

5.6k Views Asked by At

I'm trying to deploy the chaincode:

  • Hyperledger Fabric 2

  • Ubuntu 20.04

    go version go1.13.8 linux/amd64

And I always getting this ERROR:

alex@alex:~/fabric-samples/test-network$ ./network.sh deployCC
deploying chaincode on channel 'mychannel'
executing with the following
- CHANNEL_NAME: mychannel
- CC_NAME: basic
- CC_SRC_PATH: NA
- CC_SRC_LANGUAGE: go
- CC_VERSION: 1.0
- CC_SEQUENCE: 1
- CC_END_POLICY: NA
- CC_COLL_CONFIG: NA
- CC_INIT_FCN: NA
- DELAY: 3
- MAX_RETRY: 5
- VERBOSE: false
Determining the path to the chaincode
asset-transfer-basic
Vendoring Go dependencies at ../asset-transfer-basic/chaincode-go/
~/fabric-samples/asset-transfer-basic/chaincode-go ~/fabric-samples/test-network
~/fabric-samples/test-network
Finished vendoring Go dependencies
+ peer lifecycle chaincode package basic.tar.gz --path ../asset-transfer-basic/chaincode-go/ --lang golang --label basic_1.0
+ res=0
Chaincode is packaged
Installing chaincode on peer0.org1...
Using organization 1
+ peer lifecycle chaincode install basic.tar.gz
+ res=1
Error: chaincode install failed with status: 500 - failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 "go: inconsistent vendoring in /chaincode/input/src:
    github.com/golang/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    github.com/hyperledger/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    github.com/hyperledger/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    github.com/hyperledger/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    github.com/stretchr/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory
"
Chaincode installation on peer0.org1 has failed
Deploying chaincode failed

I don't know why is happening this issue. I have been reading in internet, and there is not a clear solution...

Any idea?

Thanks

4

There are 4 best solutions below

4
On

The problem was that I was using go, installed with:

apt get 

and later with:

apt install

But it didn't work until I tried to download go, from oficial source using wget:

wget https://golang.org/dl/go1.15.6.linux-amd64.tar.gz
sudo tar -xvf go1.15.6.linux-amd64.tar.gz
sudo mv go /usr/local
sudo echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc

This link helped:

https://medium.com/@kaigo/installing-golang-on-ubuntu-20-04-68137ea931

0
On

I left it as a comment, but the version is problem.

In particular, unlike 1.13, the vendering behavior is different from version 1.14 (>higher), and this seems to be a problem due to this process. – myeongkil kim


It doesn't make sense that there was a problem with the installation method. You said in the question that you have go version go1.13.8 linux/amd64 installed. If the environment variables are well set and official go works normally, it makes no sense that the execution varies depending on the installation method.

Add to, I don't think the problem was Go version, but the way of installing Go (at least in Ubuntu). – AlexAcc If you think the version is not the problem, I wonder why.
You can check it very simply. this is a method of changing only the version in the same environment.

so I actually ran it and I was able to confirm that the version problem is correct like this:


go 1.13.8

# same environment
wget https://golang.org/dl/go1.13.8.linux-amd64.tar.gz
sudo tar -xvf go1.13.8.linux-amd64.tar.gz
sudo mv go /usr/local
go env
cd $GOPATH/src/github.com/hyperledger/fabric-samples/test-network
./network.sh down
./network.sh up
./network.sh deployCC

Error: chaincode install failed with status: 500 - failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 "go: inconsistent vendoring in /chaincode/input/src:
    github.com/golang/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    github.com/hyperledger/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    github.com/hyperledger/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    github.com/hyperledger/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    github.com/stretchr/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory
"
Chaincode installation on peer0.org1 has failed

go 1.15.6

# same environment
wget https://golang.org/dl/go1.15.6.linux-amd64.tar.gz
sudo tar -xvf go1.15.6.linux-amd64.tar.gz
sudo mv go /usr/local
go env
cd $GOPATH/src/github.com/hyperledger/fabric-samples/test-network
./network.sh down
./network.sh up
./network.sh deployCC

2020-12-11 10:45:12.229 KST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nJbasic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad\022\tbasic_1.0" >
2020-12-11 10:45:12.229 KST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad
Chaincode is installed on peer0.org1
0
On

After installing newer version of golang and running the command: sudo echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc for updating the $PATH variable, I had to close and re-open wsl command prompt.

After that chaincode was successfully deployed.

0
On

I solved the issue by removing containers and volumes :

-Stop the container(s) using the following command: docker-compose down.

-Delete all containers using the following command: docker rm -f $(docker ps -a -q)

-Delete all volumes using the following command: docker volume rm $(docker volume ls -q)

Caution: the commands above would remove all your containers/Volumes, not only those created by Fabric