Setting up the Development Environment
Prerequisites
Make sure that you are using a clean and recently updated linux distribution. Distributions that are known to work are:
Ubuntu release 18.04 or later.
Fedora release 38 or later.
Amazon Linux 2.
Other Linux environments will usually be fine too, but some of the tooling might need tweaking. If you make things work for other distributions, please update this list.
This environment assumes you’re running as a non-root user with
sudo
access.Install
docker
. Please follow the instructions for docker server. Then, add your user to thedocker
group:sudo usermod -a -G docker ${LOGNAME}
, where${LOGNAME}
is replaced with your user name. Log out and log back in so that your membership of thedocker
group is seen by the shell session.Optionally install the
Docker Compose Plugin
. This is needed if you want to run thedocker compose
based test topology setup instead of the default setup based onsupervisord
. Please follow the instructions for Install Compose Plugin.
Bazel
Clone the SCION repository into the appropriate directory inside your workspace. In the commands below, replace
${WORKSPACE}
with the directory in which you want to set up the project:cd ${WORKSPACE} git clone https://github.com/scionproto/scion cd scion
We use Bazel for both building and testing. To be able to define the bazel version in the repository we use the bazelisk wrapper around bazel. To set it up simply use:
./tools/install_bazel
and make sure that
~/bin
is on yourPATH
.You can also manually install
bazelisk
and create an alias so thatbazel
will resolve to thebazelisk
command.To install the required build toolchains and scripting dependencies, run:
./tools/install_deps
Start the bazel-remote container.
We use bazel-remote to cache build artifacts from bazel. Bazel-remote can manage the disk space and does not infinitely grow like the Bazel built-in disk-cache. To start bazel-remote run:
./scion.sh bazel-remote
Build SCION services and tools.
make
Hint
This builds tools for tests in addition to the main SCION services (e.g., end2end); if you don’t require those, you can only build the SCION services by running
make build
.
Finally, check that tests run correctly:
make test make test-integration
(Optional) If you already have some code you wish to contribute upstream, you can also run the linters locally with:
make lint
Alternative: go build
Alternatively to building with bazel, the SCION services and tools can be built
with go build
.
Please be aware that this is not the recommended setup for development.
Not all checks and linters can be run in this setup. Without running all checks
locally, it is likely that there will be frustrating cycles with the CI system
rejecting your changes.
Determine the go version used in the bazel setup; the
WORKSPACE
file specifies this version in thego_register_toolchains
clause.go_register_toolchains( nogo = "@//:nogo", version = "1.21.3", )
Building with newer go versions usually works.
Install go. Either follow the official instructions or check the Ubuntu specific installation options on the golang wiki.
Decide which implementation of sqlite you want to use:
mattn: A cgo implementation. It is well established but makes go executables dependent on a minimum glibc version.
modernc: A pure go implementation. It does not cause glibc version issues but is less common. modernc is currently recommended due to the glibc issue.
Build SCION services and tools.
go build -o -tags sqlite_<impl> bin ./<service>/cmd/<service>...
where <impl> is one of modernc or mattn.
Tips and Tricks
See also
- Contribution Guide
Learn how to contribute to the SCION projects.
- Running SCION Locally
Run a SCION network on your development machine.