Kunpeng Zhang
Kunpeng Zhang

Reputation: 11

How to install third party go library in fabric container

I used the simplejson library in my chaincode, and when I try to deploy my chaincode, I got below error, how could I install this library into the fabric container? should I install this library in Order or the peer which I installed my chaincode?

When I go into the container (docker exec -it peer0 /bin/bash), and try to run go get github.com/bitly/go-simplejson, it tell me the go command not recognized.

2017-06-02 02:31:34.982 UTC [logging] InitFromViper -> DEBU 001 Setting default logging level to DEBUG for command 'chaincode'
2017-06-02 02:31:34.996 UTC [msp] GetLocalMSP -> DEBU 002 Returning existing local MSP
2017-06-02 02:31:34.996 UTC [msp] GetDefaultSigningIdentity -> DEBU 003 Obtaining default signing identity
2017-06-02 02:31:35.007 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default escc
2017-06-02 02:31:35.007 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 005 Using default vscc
2017-06-02 02:31:35.008 UTC [msp] Sign -> DEBU 006 Sign: plaintext: 0A8E070A5A0803220A73736D6368616E...454D53500A04657363630A0476736363 
2017-06-02 02:31:35.009 UTC [msp] Sign -> DEBU 007 Sign: digest: 819428A66344065ADDA8D72882891E6D2EEB6BDFD4295F7AB1D2E340B0295E16 
Error: Error endorsing chaincode: rpc error: code = 2 desc = Error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "chaincode/input/src/github.com/ssm/ssm.go:8:2: cannot find package "github.com/bitly/go-simplejson" in any of:
    /opt/go/src/github.com/bitly/go-simplejson (from $GOROOT)
    /chaincode/input/src/github.com/bitly/go-simplejson (from $GOPATH)
    /opt/gopath/src/github.com/bitly/go-simplejson

Upvotes: 1

Views: 651

Answers (1)

Ratnakar Asara
Ratnakar Asara

Reputation: 71

You might need to vendor all dependent packages (including shim) within your chaincode.

There is a good tutorial that would be very helpful https://www.youtube.com/watch?v=-mlUaJbFHcM

Upvotes: 1

Related Questions