Clone this repo:


  1. 6b1cb80 Make tools/* more robust. by Renato Mangini Dias · 3 weeks ago main
  2. 5afa3cc Remove explicit usage of --net in ffx emu by Renato Mangini Dias · 4 weeks ago
  3. 263610f Update smoke test by Renato Mangini Dias · 4 weeks ago
  4. 279ea3a Update all tests & roll Bazel SDK. by Darren Chan · 4 weeks ago
  5. ecb4de9 [version roller] Update dependencies by Renato Mangini Dias · 4 weeks ago

Fuchsia samples using the Fuchsia SDK

This repository contains instructions and source code to build, package and run Fuchsia samples using only the Fuchsia SDK. To update the dependencies of this repository, follow the instructions in


  1. Install a Bazel version no older than the one defined in the .bazelversion file, by following the instructions at In some Linux distributions, sudo apt-get install bazel should be enough.

  2. Make sure this repository has the required submodules:

    git submodule update --recursive --init
  3. Ensure that there are Fuchsia SSH keys in your host machine. You will need them for running the Fuchsia emulator.

     [[ -f "${HOME}/.ssh/fuchsia_ed25519" ]] || ssh-keygen -P "" -t ed25519 -f "${HOME}/.ssh/fuchsia_ed25519" -C "${USER}@$(hostname -f) Shared SSH Key for Fuchsia"
     [[ -f "${HOME}/.ssh/fuchsia_authorized_keys" ]] || ssh-keygen -y -f "${HOME}/.ssh/fuchsia_ed25519" > "${HOME}/.ssh/fuchsia_authorized_keys"

Build, run and test the samples

Now the repository is ready to build the samples.

  1. Build the samples:

    bazel build --config=fuchsia_x64 src:samples_repository

    This command will build all the samples and make them available as packages on a local Fuchsia repository.

  2. Fetch an emulator image and start an emulator

    tools/ffx product-bundle get workstation.qemu-x64
    tools/ffx emu start workstation.qemu-x64 --headless

    Note: Use --net user when running on MacOS

    The product bundle comes with on-demand packages in a separate repository. Use the following command to register it with the emulator:

    tools/ffx target repository register -r workstation.qemu-x64 --alias
  3. Register the package repositories

    tools/ffx repository add-from-pm -r bazel-bin/src/
    tools/ffx target repository register -r
  4. (optional) watch the device log in a separate window

    tools/ffx log
  5. Run a hello world component

    tools/ffx component run fuchsia-pkg:// --recreate

    Watch in the log that the message “Hello, World!” is printed. Modify the Hello world message in src/hello_world/, repeat steps 1 and 3, and see that the log shows the new message.

  6. Run the echo sample

    tools/ffx component run fuchsia-pkg:// --recreate

    Watch the message “Hello, Alice, Bob, Spot!” in the log. Modify the FAVORITE_ANIMAL environment variable in src/echo/meta/echo.cml, repeat steps 1 and 3 and see that the log shows the new message.

  7. Run unit tests for the hello world sample

    tools/ffx test run fuchsia-pkg://
  8. Run the routing sample

    tools/ffx component create /core/ffx-laboratory:echo_realm fuchsia-pkg://
    tools/ffx component start /core/ffx-laboratory:echo_realm/echo_client

    Watch the message “Server response: Hello Fuchsia!” in the log:

    tools/ffx log --filter echo_client
  9. Run integration tests for the routing sample

    tools/ffx test run fuchsia-pkg://