This guide provides instructions for the following tasks:
Prerequisites
The Fuchsia project requires curl
, unzip
, and git
to be up-to-date:
For Linux, install or update the following packages:
sudo apt-get install curl git unzip
For macOS, install the Xcode command line tools:
xcode-select --install
Download Fuchsia source
Fuchsia's bootstrap script creates a fuchsia
directory
and downloads the content of the Fuchsia source repository to this new
directory.
To download the Fuchsia source, do the following:
Go to the directory where you want to create your
fuchsia
directory, for example:cd ~
Run the bootstrap script:
curl -s "https://fuchsia.googlesource.com/fuchsia/+/HEAD/scripts/bootstrap?format=TEXT" | base64 --decode | bash
If you see the
Invalid authentication credentials
error during the bootstrapping process, see Authentication error for help.
Set up environment variables
Fuchsia recommends updating your shell script to perform the following actions (see Update your shell script for the instructions):
Add the
.jiri_root/bin
directory to yourPATH
.The
.jiri_root/bin
directory in the Fuchsia source contains thejiri
andfx
tools are essential to Fuchsia workflows. Fuchsia uses thejiri
tool to manage repositories in the Fuchsia project. Thefx
tool helps configure, build, run, and debug Fuchsia. The Fuchsia toolchain requiresjiri
to be available in yourPATH
.Source the
scripts/fx-env.sh
file.Although it's not required, sourcing the
fx-env.sh
script enables useful shell functions in your terminal. For instance, it creates aFUCHSIA_DIR
environment variable and provides thefd
command for navigating directories with auto-completion (see comments infx-env.sh
for more information).
Update your shell script
Update your shell script to automatically set up Fuchsia environment variables in your terminal.
The following steps use a bash
terminal as an example. If you are using zsh
replace
~/.bashrc
with ~/.zshrc
in the following example.
Do the following:
Use a text editor to open your
~/.bashrc
file, for example:nano ~/.bashrc
Add the following lines your
~/.bashrc
file:export PATH=~/fuchsia/.jiri_root/bin:$PATH source ~/fuchsia/scripts/fx-env.sh
Save the file and exit the text editor.
To update your environment variables, run the following command:
source ~/.bashrc
Verify that you can run the following commands from any directory without error:
jiri help
fx help
Next steps
See Configure and build Fuchsia in the Getting started guide for the next steps.
Troubleshoot
Authentication error
If you see the Invalid authentication credentials
error during the bootstrap
process, your ~/.gitcookies
file may contain cookies from some repositories in
googlesource.com
that the bootstrap script wants to check out anonymously.
To resolve this error, do one of the following:
- Follow the onscreen directions to get passwords for the specified repositories.
- Delete the offending cookies from the
.gitcookies
file.
Work on Fuchsia without updating your PATH
The following sections provide alternative approaches to the Update your shell script section:
Copy the tool to your binary directory
If you don't wish to update your environment variables, but you want jiri
to
work in any directory, copy the jiri
tool to your ~/bin
directory, for
example:
cp ~/fuchsia/.jiri_root/bin/jiri ~/bin
However, you must have write access to the ~/bin
directory without sudo
. If
you don't, jiri
cannot keep itself up-to-date.
Add a symlink to your binary directory
Similarly, if you want to use the fx
tool without updating your environment
variables, provide the fx
tool's symlink in your ~/bin
directory, for
example:
ln -s ~/fuchsia/scripts/fx ~/bin
Alternatively, run the fx
tool directly using its path, for example:
./scripts/fx help
In either case, you need jiri
in your PATH
.