Clone this repo:


  1. 700a782 add test scripts for use in CI by Dan Johnson · 3 weeks ago main
  2. 54c79f9 update OWNERS by Dan Johnson · 5 weeks ago
  3. 1e025e5 Merge "Add Rust hello world example" into main by Tyler Mandry · 5 weeks ago
  4. 9f83228 Fix bootstrap symlink by Tyler Mandry · 5 weeks ago
  5. f3c21d5 Add Rust hello world example by Tyler Mandry · 5 weeks ago

Fuchsia samples using the Fuchsia SDK with Rust

Note: Rust is not yet supported in the Fuchsia SDK.

TODO: Update instructions

This repository contains instructions and source code to build, package and run Fuchsia samples using only the Fuchsia SDK.


  1. Make sure this repository has the required submodules:

    git submodule update --recursive --init
  2. Run the bootstrap script that downloads the appropriate Bazel binary:

  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. Fetch the system images

    tools/ffx product-bundle get workstation_eng.qemu-x64 --repository workstation-repo

    Note: if the product-bundle command above fails with an error message that states that there are multiple product bundles with the same name, you can either specify the fully qualified URL as printed in the error message that corresponds to your SDK version (use tools/ffx sdk version if needed), or you can wipe out old and unused product bundles in the pbms storage, which should be located in ~/.local/share/Fuchsia/ffx/pbms on Linux, or ~/Library/Fuchsia/ffx/pbms on MacOS.

  2. Start the emulator

    tools/ffx emu start workstation_eng.qemu-x64 --headless
  3. 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-repo --alias
  4. (optional) watch the device log in a separate window

    tools/ffx log
  5. Run a hello world component

    tools/bazel run --config=fuchsia_x64 src/hello_world:pkg.component

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

  6. Run the echo sample

    tools/bazel run --config=fuchsia_x64 src/echo:pkg.component

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

  7. Run unit tests for samples

    tools/bazel test --config=fuchsia_x64 src/hello_world:test_pkg
    tools/bazel test --config=fuchsia_x64 src/echo:test_pkg