Command missing when running through Hyperledger tutorial—cannot package chaincode - hyperledger-fabric

When working through the Hyperledger tutorial docs, there is a snippet that says to type:
peer lifecycle chaincode package mycc.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/abstore/go/ --lang golang --label mycc_1
in the CLI. However, when trying to run it, I get an error that says:
Error: unknown command "lifecycle" for "peer"
When typing peer -h in the CLI, the results show that the "lifecycle" command isn't available for "peer".
Am I running a wrong version of the docker container? What is going on?

I ended up figuring this out, posting solution here for future reference: turns out I downloaded the wrong docker images. I had hyperledger 1.4.1 images and I needed the 2.0 alphas. To check versions I just ran "docker images" in the cli.

Related

Error when installing chaincode - failed to calculate dependencies: incomplete package

I am try to installing Chaincode, follow the tutorial of hyperledger. But when I try to run the command
peer chaincode install -p chaincodedev/chaincode/sacc -n mycc -v 0
The terminal gives error message
Error: error getting chaincode deployment spec for mycc: error getting chaincode package bytes: failed to calculate dependencies: incomplete package: github.com/hyperledger/fabric-chaincode-go/shim
I see some other people got similar issue, but there is no answer yet. I am new to these stuffs, so any suggestions can be helpful.
I solved it today:
After loging into CLI contaier execute the following command (import the shim package). This will import the package into cli container where the chaincode will be compiled.
go get github.com/hyperledger/fabric-chaincode-go/shim
then execute
peer chaincode install -p chaincodedev/chaincode/sacc -n mycc -v 0
It will work cheers.
You don't say what version of Fabric and samples you are using, but this looks like a change that was made for Fabric 2.0 and described in the release notes "The shim package and dependencies for go chaincode are no longer included in
the chaincode build environment."
There is more detail in the associated Jira entry.
Try downloading the shim package to the GOPATH
go get github.com/hyperledger/fabric-chaincode-go/shim
This downloads the shim package to /src/github.com/hyperledger/fabric-chaincode-go/shim inside your GOPATH . Then provide the path to this shim package inside import in your chaincode.
It should be like below:
import (
"github.com/hyperledger/fabric-chaincode-go/shim"
)
In my case the reason was incorrect path. CLI container work dir has already chaincodedev part of the path
cli:
...
working_dir: /opt/gopath/src/chaincodedev
You can do following to validate if this is true in your case
docker exec -it cli bash
pwd
You have to see /opt/gopath/src/chaincodedev.
So all I needed to do is just remove chaincodedev from command path
peer chaincode install -p chaincode/sacc -n mycc -v 0

Where is nodejs chaincode stored in a container? and is it compiled?

I am learning hyperledger fabric and am curious where is the nodejs chaincode stored in a container after it has been installed and instantiated?
Also the docs say the chaincode is compiled - is that applicable to nodejs also? How is nodejs compiled? What compiler is used? Is the compilation output some VM bytecode or is it machine code?
The NodeJS chaincode can be found under /usr/local/src of the docker container in which its instantiated. It is not compiled into anything.
$ docker exec -it dev-peer1-jnj-mycc-1.0 /bin/bash
root#0dbcfb72e6d8:/# ls /usr/local/src
chaincode.js node_modules package-lock.json package.json

startFabric.sh fails with docker compose command not find

I am following the tutorial on writing your first application to make a sample hyperledger fabric application. I am using Ubuntu 16.04 and I have installed prerequisites as well as binaries and docker images. When I move into fabric-samples/fabcar, after npm install. I run:
./startFabric.sh
I get the following error:
docker-compose -f docker-compose.yml down.
./start.sh: line 13: docker-compose: command not found.
I looked into ./startFabric.sh by nano. Line 13 is as follows:
starttime=$(date +%s)
LANGUAGE=${1:-"golang"}
This is a screen shot of the error I get:
It may be irrelevant, but I have also issues running .byfn -m up as I have posted on issue with byfn. I am not sure if these two are related. But obviously neither can I start fabric, nor can I build a network.
I appreciate any help to solve the issue.
Thank you for your attention.
You should install docker. If you already installed docker, you should check if your docker bin folder is referenced in your PATH environment variable.
https://docs.docker.com/install/

Hyperledger composer install is not installing business network

I am using Ubuntu 16.04.2 LTS as VM, and composer v0.19.1. I have installed all the prerequisites as well as hyperledger composer and fabric by folowing the documents at hyperledger composer playgroung. I have followed the tutorial line by line to make a business network. When I want to install the business network by the following command:
composer network install --card PeerAdmin#hlfv1 --archiveFile tutorial-network#0.0.1.bna
It gives me the following error:
No connection type provided, probably because the connection profile has no 'x-type' property defined.
The screen shot of the error is provided as well.
I have checked and made sure that PeerAdminCard exists by
composer card list
And of course Fabric is started. I highly appreciate if someone mentions what I am doing wrong. Thank you.
The 2nd problem you are having is with the createPeerAdminCard.sh script - you are using an 'old' version of the where the default is Fabric v1.0.
The default is assuming hlfv1 because the environment variable FABRIC_VERSION is not set. So the createPeerAdminCard.sh script assumes you want a hlfv1 card and creates the files, but Composer v0.19 can't import that old card at the end of the script.
The fast solution is to export FABRIC_VERSION="hlfv11" then run the createPeerAdminCard.sh
I suspect that you may also have a problem with hlfv1 / v11 with the Fabric. You can check the Fabric version by running docker ps or docker images - if they have 1.0 at the end you need to remove them all and run downloadFabric.sh in the same window as you exported the FABRIC_VERSION variable, then run startFabric.sh
You need to remember to export that environment variable everytime you run one of those Fabric Tools scripts - so the better answer might be to delete the Fabric Tools folder and all docker Images and Containers - then download a new version of Fabric tools which includes the new default for Fabric 1.0
I was getting exactly the same error as you. Turns out if you update the Composer from version 0.16 or earlier, the card store still has the old PeerAdmin card which is now not compatible with version 0.19. Even deleting the card using composer card delete --card <CARD_NAME_HERE> doesn't work. The quick and dirty solution is to manually delete the card store. It is normally in ${HOME}/.composer, so to deleting this directory should work.
rm -fr ${HOME}/.composer
For your other problems, the easiest solution is to replace your older version of Hyperledger and do a new install from scratch. That means removing composer as well as killing and removing all previous Docker containers:
docker kill $(docker ps -q)
docker rm $(docker ps -aq)
docker rmi $(docker images dev-* -q)
Basically start from a clean slate if you can!
When you upgrade the composer modules from an earlier version to the latest version connection profile will not be compatible with the system. An ideal solution is to remove and delete the composer folder and create the .composer folder from the home directory and try creating PeerAdmin card again. Once that is done you are good to go for installing the starting the new business network application.

Error installing chaincode while deploying .bna file using Hyperledger Composer on local machine with Fabric 1.0.0 Production Release

I am following the my-network tutorial from the Hyperledger Composer docs and am getting the following error when deploying the .bna file to Fabric.
The command I use is:
composer network deploy -a my-network.bna -p hlfv1 -i PeerAdmin -s randomString
Error message:
✖ Deploying business network definition. This may take a minute...
Error: error trying deploy. Error: error trying install chaincode. Error: Connect Failed
Command failed
I am on OSX and have all the required preliminaries.
I had exactly the same error - assuming you are following the Hyperledger Composer Developer Guide.
I think this error comes about because at the end of installing the developer environment you run a command to stop and tear down the Fabric, but then the Developer Guide does not instruct you to restart it.
To fix I changed back to the fabric-tools directory and re-started Fabric:
cd ../..
./startFabric.sh
Returning to the original directory I then tried deploying it again:
cd my-network/dist/
composer network deploy -a my-network.bna -p hlfv1 -i PeerAdmin -s randomString
This got me to the Command succeeded all clear the guide tells you to expect.
Good luck.
Go to the directory which contains the bna file, usually; it is under your sample folder\dist
Then run the following:
$ composer network install -a my-network.bna -c PeerAdmin#hlfv1

Resources