Troubleshoot and fix sync issues

This page explains how to troubleshoot and fix issues related to the repo sync command.

Fix network issues

This section provides several suggestions for fixing network issues that can cause unsuccessful syncs.

Use authentication to avoid quota barriers

To protect the servers against excessive use, each IP address that's used to access source is associated with a quota.

When sharing an IP address with other users, such as when accessing the source repositories from beyond a NAT firewall, quotas can trigger for normal patterns. For example, a quota can trigger when several users sync new clients from the same IP address, within a short period.

To avoid triggering quotas, you can use authenticated access, which uses a separate quota for each user, regardless of the IP address.

To enable authenticated access:

  1. Create a password with the password generator.

  2. Run the following command to convert your client to use automatic authentication (without changing branch):

    $ repo init -u

    Note that the /a/ directory prefix triggers automatic authentication.

Configure for proxy use

If you're downloading source from behind a proxy, as is common in some corporate environments, ensure you explicitly specify a proxy for Repo to use by running these commands:

$ export HTTP_PROXY=http://proxy_user_id:proxy_password@proxy_server:proxy_port
$ export HTTPS_PROXY=http://proxy_user_id:proxy_password@proxy_server:proxy_port

Adjust TCP/IP settings to avoid connectivity issues

While it's rare, Linux clients can experience connectivity issues, such as getting stuck in the middle of downloads while receiving objects. To improve this issue, adjust the settings of the TCP/IP stack or use non-parallel connections. You must have root access to modify the TCP setting. To modify the setting, issue the following commands:

$ sudo sysctl -w net.ipv4.tcp_window_scaling=0
$ repo sync -j1

Use a local mirror to avoid network latency

When using several clients, you can create a local mirror of the entire server content and sync clients from that mirror without accessing the network. Follow these instructions to create a local mirror in at ~/aosp-mirror/ and sync clients against that mirror:

  1. Create and sync the mirror:

    $ mkdir -p /usr/local/aosp/mirror
    $ cd /usr/local/aosp/mirror
    $ repo init -u --mirror

    These commands create a local mirror in /user/local/aosp/mirror and initialize the mirror using the --mirror flag with the repo init command.

  2. To sync clients from the mirror:

    $ mkdir -p /usr/local/aosp/main
    $ cd /usr/local/aosp/main
    $ repo init -u /usr/local/aosp/mirror/platform/manifest.git
    $ repo sync
  3. Finally, follow these commands to sync the mirror against the server and sync the client against the mirror:

    $ cd /usr/local/aosp/mirror</code>
    $ repo sync
    $ cd /usr/local/aosp/main
    $ repo sync

It's possible to store the mirror on a LAN server and to access it over NFS, SSH, or Git. It's also possible to store it on a removable drive and to pass that drive among users or machines.

Use a partial clone

If you're using Git version 2.19 or later, specify --partial-clone when performing repo init to overcome any low-latency network issues:

  $ repo init -u -b main --partial-clone --clone-filter=blob:limit=10M

Instead of initializing Repo to download everything, this command downloads Git objects as they are needed.

Fix specific sync issues

This page details some known issues you may encounter while trying to sync the Android source code.

Commands fail with 403 or 500 error (proxy issues)

The repo init or repo sync commands might fail with either a 403 or 500 error. Most often these errors are related to HTTP proxies struggling to handle the large data transfers.

While there isn't a specific fix to these errors, using the most recent Python version and explicitly using repo sync -j1 can sometimes help.