Setting up the Development Environment

Prerequisites

  1. 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.

  2. Install docker. Please follow the instructions for docker server. Then, add your user to the docker 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 the docker group is seen by the shell session.

    Optionally install docker-compose. This is needed if you want to run the docker-compose based test topology setup instead of the default setup based on supervisord. Please follow the instructions for docker-compose.

Bazel

  1. 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
    
  2. 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 your PATH.

    You can also manually install bazelisk and create an alias so that bazel will resolve to the bazelisk command.

  3. To install the required build toolchains and scripting dependencies, run:

    ./tools/install_deps
    
  4. 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
    
  5. Build SCION services and tools.

    make
    
  6. Finally, check that tests run correctly:

    make test
    make test-integration
    
  7. (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.

  1. Determine the go version used in the bazel setup; the WORKSPACE file specifies this version in the go_register_toolchains clause.

    go_register_toolchains(
        nogo = "@//:nogo",
        version = "1.21.1",
    )
    

    Building with newer go versions usually works.

  2. Install go. Either follow the official instructions or check the Ubuntu specific installation options on the golang wiki.

  3. 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.

  4. 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.