FFX Doctor Plugin

ffx doctor is a tool to diagnose issues with the ffx development environment.

It performs a series of checks on the host environment, the ffx daemon, and target devices to identify common configuration and operational problems.

Code Structure

The plugin is organized into several modular files:

  • lib.rs: Contains the main tool entry point (DoctorTool), the plugin orchestration logic (doctor), and the integration tests.
  • types.rs: Shared types, enums (e.g., StepType), and traits (e.g., DoctorStepHandler).
  • daemon.rs: Checks related to the ffx daemon (status, restart, PID verification).
  • environment.rs: Environment-related checks (SSH keys, inotify watches, lock files, emulator instances).
  • target.rs: Target discovery, collection, and individual target diagnostics.
  • usb.rs: Checks for the ffx-usb-driver.
  • network.rs: Internal Google network checks (if applicable).
  • record.rs: Logic for generating doctor records (zip files containing logs and config).

Build

To build the doctor plugin, build ffx:

fx build src/developer/ffx

Test

Run the unit tests:

fx test ffx_doctor_tests