Whenever I try to get a complicated development environment up and running on my machine, I make notes as I go along. This week I’ve been grappling with the IBM Hyperledger contribution, called Fabric. These are just rough notes, but they may help someone else out, so I thought I’d put them up on a blog post. I used a clean install of Ubuntu 16.04 LTS on a Packard Bell with an AMD C-50 dual core processor, 3 GB of RAM, and a 500 GB hard drive. It’s a fairly slow device, really only designed for casual web browsing and email.

The instructions below set you up to develop Fabric further, and submit changes (gerrits) to the main development branch for inclusion in the source code. But of course you can also just use it to play about, as long as you don’t do any git commits.


Check that your PC supports KVM, which is needed for running a virtual machine on your machine using Virtualbox. I got 90% through the install and found that my trusty old Toshiba Satellite L300 didn’t have a processor that supports virtualisation.

$ sudo apt-get install cpu-checker
$ sudo kvm-ok

If you see:

INFO: /dev/kvm exists
KVM acceleration can be used

then your CPU is new enough to support the VM needed. Probably. If you see

INFO: Your CPU does not support KVM extensions
KVM acceleration can NOT be used

then your CPU is not good enough.


The Go language

Fabric relies on the Go language, which is a C-like programming language developed fairly recently.

Make sure you have git

$ sudo apt-get install git

Install the Go programming language

$ sudo apt-get install golang

In your home directory make a Go directory

$ mkdir Go
$ cd Go

Set your Go path for working on Go stuff:

$ export GOPATH=$HOME/Go
$ export PATH=$PATH:$GOPATH/bin

Check it works with a hello world project. First make the project source location:

$ mkdir -p $GOPATH/src/github.com/user/hello

Create a file called hello.go in the hello directory, containing the following:

package main

import "fmt"

func main() {
 fmt.Printf("Hello, world.\n")
 }

See how C-like it is? There are packages that need to be imported, and the program starts running in a main function. Compile it with:

$ go install github.com/user/hello

Check there is now a hello executable in the bin folder with:

$ hello
Hello, world.

Great. We have Go installed and working.


Vagrant and VirtualBox

Vagrant provides a consistent development environment so that developers all around the world working on a project have the same system. It runs on top of VirtualBox, which is a virtual machine running within your main OS. The upside is that a lot of time is saved by everyone having the same system. The downside is that developers aren’t really testing much in the way of different platforms and configurations. I suppose if the production environment ends up being the same all will be well.

Get Vagrant installed:

$ sudo apt-get install vagrant

And get VirtualBox:

$ sudo apt-get install virtualbox

If like me, you have a second drive with lots of space, go to the dash, type VirtualBox, click on the icon, then
in the menu bar chose File > Preferences, select General in the dialog, and select your VirtualBox image directory
on your bigger drive (by default it’s in your Home directory, and mine had very little space).


Get the Fabric code from Hyperledger.org

Sign up with Linux Foundation at linuxfoundation.org by creating a new username and password, and respond to the verification email.

Generate a key pair for your work environment:

$ ssh-keygen -t rsa -C "Your Name your@email.address"

Go to the Gerrit hyperledger website at https://gerrit.hyperledger.org/r/#/admin/projects/fabric and log in (top right, sign in) with your Linux Foundation ID.
Click on your account name in the upper right corner.
From the pop-up menu, select Settings.
On the left side menu, click on SSH Public Keys.
Paste the contents of your public key ~/.ssh/id_rsa.pub and click Add key.

You can now get the fabric code. First make the required folders:

$ cd $GOPATH/src
$ mkdir -p github.com/hyperledger
$ cd github.com/hyperledger

Then run the git clone command to pull it all on to your machine. Swap the two occurrences of LFID in the command below for your Linux Foundation user ID.

$ git clone ssh://LFID@gerrit.hyperledger.org:29418/fabric && scp -p -P 29418 LFID@gerrit.hyperledger.org:hooks/commit-msg fabric/.git/hooks/

Then fire up the virtual machine with the command:

$ cd $GOPATH/src/github.com/hyperledger/fabric/devenv
$ vagrant up

It takes quite a long time the first time you do this to download and setup the VM. You’ll see a lot of green, blue and red paragraphs scroll by. IBM recommends you go and get a coffee; I suggest you go and have a light lunch, because it’s a long slow process.