I am upgrading chaincode by changing the version in startFabric.sh file and then running ./startFabric.sh javascript command. So is this the right way or is there any command like peer chaincode install -p chaincodedev/chaincode/sacc -n mycc -v 0
Related
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
I have started a fabric network with three orgs one pear for each org and one orderer. Created one channel and added the peers to the channel.But when i try to install the chaincode it says directory not found. I also mounted the volume inside my cli config.
i am entering cli bash before entering the command also checked using peer channel list command to see if my peer is joined in a channel.
my cli config
- /var/run/:/host/var/run/
- ./../chaincode/:/opt/gopath/fabric-samples/food-network/chaincode
- ./crypto-config:/opt/gopath/fabric-samples/food-network/crypto-config/
my peer command
peer chaincode install -n chain chain -v 1.0
error
Error: open /opt/gopath/fabric-samples/food-network/chaincode/chain: no such file or directory
my chain code is named chain.go. Its a go file and it has been built.
also when i try this command:
peer chaincode install -n chain -p chain -v 1.0
it gives this error:
error getting chaincode code chain: path to chaincode does not exist: /opt/gopath/src/chain
In order to install chaincode, you need to build a chaincode package. You can either run
peer chaincode package ...
followed by
peer chaincode install ...
or you can use the -p option with peer chaincode install to package and install together.
When using the peer cli to package chaincode, it will look for your Go chaincode under $GOPATH/src. The cli container has its GOPATH set to /opt/gopath.
I'm not sure where your actual chaincode is located, but assuming your your Go code is located in ./../chaincode on your host, you would need to change your volume mount to
- ./../chaincode/:/opt/gopath/src/chaincode
and then you can run
peer chaincode install -n chain -p chaincode -v 1.0
I am trying to add 1 column to my mode.cto file. Once I added and apply the following commands, I was not able to see previous data:
composer archive create -t dir -n .
composer network install -a hash-health\#0.0.3.bna -c peerAdmin#hlfv1
composer network upgrade -c peerAdmin#hlfv1 -n hash-health -V 0.0.3
But, I noticed every time there is a new docker instance running.
I want to see my old data.
This link should provide you with help around your issue https://hyperledger.github.io/composer/latest/reference/model-compatibility
Please be aware that Hyperledger Composer is now deprecated and you should focus on using the hyperledger fabric programming models. Of course you can continue to use hyperledger composer for education purposes if you wish
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.
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