nautechsystems/nautilus_trader · error · anyhow::Error

At least one --address or --addresses-file entry is required

Error message

At least one --address or --addresses-file entry is required

What it means

`load_pool_addresses` in the blockchain analyze CLI aggregates addresses passed via `--address` (repeatable) and entries in `--addresses-file`. If after merging both sources no address remains, it bails with this anyhow error, because pool analysis needs at least one target address. It is a deliberate fail-fast guard against running an analysis over an empty input set.

Source

Thrown at crates/cli/src/blockchain/analyze.rs:593

    addresses: Vec<String>,
    addresses_file: Option<String>,
) -> anyhow::Result<Vec<String>> {
    let mut pool_addresses = addresses;

    if let Some(addresses_file) = addresses_file {
        let contents = fs::read_to_string(&addresses_file)
            .map_err(|e| anyhow::anyhow!("Failed to read addresses file {addresses_file}: {e}"))?;

        for line in contents.lines() {
            let trimmed = line.trim();
            if !trimmed.is_empty() && !trimmed.starts_with('#') {
                pool_addresses.push(trimmed.to_string());
            }
        }
    }

    if pool_addresses.is_empty() {
        anyhow::bail!("At least one --address or --addresses-file entry is required");
    }

    Ok(pool_addresses)
}

#[derive(Debug)]
enum PoolAnalysisOutcome {
    Success(PoolAnalysisSuccessOutcome),
    NeedsBootstrap(PoolNeedsBootstrapOutcome),
}

#[derive(Debug)]
struct PoolAnalysisSuccessOutcome {
    pool_address: String,
    target_block: u64,
    snapshot_block_position: BlockPosition,
    positions: usize,
    ticks: usize,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Pass at least one address with `--address 0x...` (repeat the flag for multiple pools)
  2. Create/populate the addresses file (one address per line) and pass it via `--addresses-file <path>`
  3. Check that the file is non-empty and lines are not blank/comment-only
  4. Verify shell quoting/expansion so flags actually reach the CLI (e.g. `$ADDRESSES` not unset)

Example fix

// before
mycli blockchain analyze-pools --chain ethereum
// after
mycli blockchain analyze-pools --chain ethereum --address 0xdAC17F958D2ee523a2206206994597C13D831ec7
Defensive patterns

Strategy: validation

Validate before calling

if addresses.is_empty() && addresses_file_entries.is_empty() {
    eprintln!("Provide --address or --addresses-file with at least one entry");
    std::process::exit(2);
}

Type guard

fn has_addresses(cli: &[String], file_entries: &[String]) -> bool {
    !cli.is_empty() || !file_entries.is_empty()
}

Prevention

When it happens

Trigger: Running `blockchain analyze-pools` without `--address` and without `--addresses-file`; providing an addresses file that exists but is empty or contains only blank lines/comments; passing flags with values that are all whitespace after trimming.

Common situations: Forgot to paste the address argument; a script passes an env var that is unset, so the file path/entries are empty; CI config points at a placeholder empty file; wrong flag spelling so neither address source is populated.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/3df112085d74137c. Report an issue: GitHub.