Johan
Johan

Reputation: 61

Hyperledger-fabric fails to instantiate chaincode

I am unable to instantiate chaincode in Hyperledge Fabric.

When executing:

peer chaincode instantiate -o orderer -n test_cc -C test-channel -v 0.1 -c '{"Args":["initLedger"]}'

I get the error:

peer0       | 2018-04-17 13:02:11.097 UTC [dockercontroller] Start -> ERRO 046 start-could not start container: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}

When searching the internet, the error message is the same as on the original post at [OCI Runtimer Error when installing Hyperledger Chaincode via Java-SDK and [OCI runtime error when sending Hyperledger Fabric's chaincode instantiation request to peers, but the comments on these posts did not led me to the solution.

I am using the following software versions: Hyperledger 1.1.0 Docker version 18.03.0-ce (on Linux), Hyperledger Docker images: x86_64-1.1.0

The following steps succeed:

(Steps according to Hyperledger documentation: [http://hyperledger-fabric-docs.readthedocs.io/en/latest/chaincode4noah.html])

In the CLI Docker container, files are located in the directory /opt/gopath/src/chaincode/go/test_cc/, where 4 files are present: test_cc, test_cc.go, test_cc_pack.out, test_cc_signed_pack.out (the binary, source file, packaged file and signed package file).

The full output of the orderer and peer is:

orderer    | 2018-04-17 13:29:43.617 UTC [orderer/common/server] Broadcast -> DEBU 167 Starting new Broadcast handler
orderer    | 2018-04-17 13:29:43.617 UTC [orderer/common/broadcast] Handle -> DEBU 168 Starting new broadcast loop for 172.18.0.6:41228
couchdb    | [notice] 2018-04-17T13:29:43.624931Z nonode@nohost <0.16042.3> b5d38cd27d couchdb:5984 172.18.0.5 undefined GET /test-channel_lscc/test_cc?attachments=true 404 ok 2
peer       | 2018-04-17 13:29:44.416 UTC [dockercontroller] Start -> ERRO 04a start-could not start container: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer       | 2018-04-17 13:29:44.647 UTC [chaincode] Launch -> ERRO 04b launchAndWaitForRegister failed: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer       | 
peer       | error starting container
peer       | 2018-04-17 13:29:44.647 UTC [endorser] simulateProposal -> ERRO 04c [test-channel][39e4414a] failed to invoke chaincode name:"lscc" , error: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer       | 
peer       | error starting container
orderer    | 2018-04-17 13:29:44.648 UTC [orderer/common/broadcast] Handle -> DEBU 169 Received EOF from 172.18.0.6:41228, hangup
orderer    | 2018-04-17 13:29:44.648 UTC [orderer/common/server] func1 -> DEBU 16a Closing Broadcast stream

It looks like there is some path issue, but the process of the creation of the chaincode container and the variables which influence this process.

I'm messing around with this issue for few days(!) now, tried all path combinations like placing the file in /opt/gopath/bin, etcetera, but to no avail.

Someone who can shine a light on this issue? Or knows what the correct paths are and where they are, or where they should be defined?

Thanks

Upvotes: 2

Views: 1902

Answers (1)

Johan
Johan

Reputation: 61

The issue was that in the Go source files I used 'package test_package', which, when building, does not create an executable file, but a linkable object file.

Having 'package main' in my Go files, then rebuilding and repackaging, made the 'peer chaincode install' and 'peer chaincode instantiate' commands working as expected.

Upvotes: 4

Related Questions