Setting up the development environment
The current development environment utilizes Vagrant running an Ubuntu image, which in turn launches Docker containers. Conceptually, the Host launches a VM, which in turn launches Docker containers.
Host -> VM -> Docker
This model allows developers to leverage their favorite OS/editors and execute the system in a controlled environment that is consistent amongst the development team.
- Note that your Host should not run within a VM. If you attempt this, the VM within your Host may fail to boot with a message indicating that VT-x is not available.
- Git client
- Go - 1.6 or later
- Vagrant - 1.7.4 or later
- VirtualBox - 5.0 or later
BIOS Enabled Virtualization - Varies based on hardware
Note: The BIOS Enabled Virtualization may be within the CPU or Security settings of the BIOS
Set your GOPATH
Make sure you have properly setup your Host’s GOPATH environment variable. This allows for both building within the Host and the VM.
Note to Windows users
If you are running Windows, before running any
git clone commands, run the following command.
git config --get core.autocrlf
core.autocrlf is set to
true, you must set it to
false by running
git config --global core.autocrlf false
If you continue with
core.autocrlf set to
vagrant up command will fail with the error
./setup.sh: /bin/bash^M: bad interpreter: No such file or directory
Cloning the Peer project
Create a fork of the fabric repository using the GitHub web interface. Next, clone your fork in the appropriate location.
cd $GOPATH/src mkdir -p github.com/hyperledger cd github.com/hyperledger git clone https://github.com/<username>/fabric.git
Boostrapping the VM using Vagrant
Now you’re ready to launch Vagrant.
cd $GOPATH/src/github.com/hyperledger/fabric/devenv vagrant up
Go get coffee… this will take a few minutes. Once complete, you should be able to
ssh into the Vagrant VM just created.
Building the fabric
Once you have your vagrant development environment established, you can proceed to build and test the fabric. Once inside the VM, you can find the peer project under
$GOPATH/src/github.com/hyperledger/fabric. It is also mounted as
NOTE: any time you
git clone any of the projects in your Host’s fabric directory (under $GOPATH/src/github.com/hyperledger/fabric), the update will be instantly available within the VM fabric directory.
NOTE: If you intend to run the development environment behind an HTTP Proxy, you need to configure the guest so that the provisioning process may complete. You can achieve this via the vagrant-proxyconf plugin. Install with
vagrant plugin install vagrant-proxyconf and then set the VAGRANT_HTTP_PROXY and VAGRANT_HTTPS_PROXY environment variables before you execute
vagrant up. More details are available here: https://github.com/tmatilai/vagrant-proxyconf/
NOTE: The first time you run this command it may take quite a while to complete (it could take 30 minutes or more depending on your environment) and at times it may look like it’s not doing anything. As long you don’t get any error messages just leave it alone, it’s all good, it’s just cranking.
NOTE to Windows 10 Users: There is a known problem with vagrant on Windows 10 (see mitchellh/vagrant#6754). If the
vagrant up command fails it may be because you do not have Microsoft Visual C++ Redistributable installed. You can download the missing package at the following address: http://www.microsoft.com/en-us/download/details.aspx?id=8328