Skip to content

Environment Variables

alexjlan edited this page Apr 21, 2020 · 10 revisions

Make sure these environment variables are set properly to ensure the OneLedger Protocol runs properly on your system.

First check that you have a valid GOPATH set for your current profile:

$ echo $GOPATH
YOUR_PREFIX_HERE/go

If you don't see any output from the above command, you need to manually set your GOPATH directory.

Setting up the GOPATH

First make your desired folder for the GOPATH:

$ mkdir ~/go

Set a GOPATH environment variable in your shell startup script. On macOS, this is ~/.bash_profile. For different operating systems or shells, the path may be different. For Ubuntu, it may be ~/.bash_profile or ~/.bashrc.

For the following examples, we'll assume your shell startup script is in ~/.bash_profile.

Add the GOPATH environment variables (make sure it matches the directory you created above):

$ echo export GOPATH=\"\$HOME/go\" >> ~/.bash_profile
$ echo export PATH=\"\$PATH:\$GOPATH/bin\" >> ~/.bash_profile

By default, go will be installed into the directory /usr/local/go, make sure that not using this directory as the $GOPATH as it will cause permission denial issue when starting to run make commands.

Setting up Oneledger Protocol environment variables

Now set up the environment variables for the Oneledger Protocol:

$ echo export OLROOT="$GOPATH/src/github.com/Oneledger" >> ~/.bash_profile
$ echo export OLTEST=1 >> ~/.bash_profile 
$ echo export OLDATA="$GOPATH/test" >> ~/.bash_profile

You can log out and log back in to reflect these changes on your system, or you can immediately add these variables by sourcing your startup script.

$ source ~/.bash_profile