astral-sh/ruff · error

{}

Error message

{}

What it means

Thrown while constructing ty's ProjectDatabase: resolving the merged project options into settings failed. The message is the pretty-printed options error, which names the offending config file, the invalid setting, and the reason. This is ty's generic 'your configuration is invalid' path (db.rs:146 wraps error.pretty(&db) in anyhow).

Source

Thrown at crates/ty_project/src/db.rs:146

        //   cache and load the cache if it exists.
        //   we may want to have a dedicated method for this?
        // Important: For persistent caching it's essential that we can compute the
        // cache key before loading the DB. Because of that, access to the `db` (other than system and vendored) is
        // strictly forbidden before resolving the `program_settings`.

        let merged_options = project_metadata.to_merged_options();

        let (program_settings, program_settings_diagnostics) = strategy
            .to_anyhow(merged_options.to_program_settings(db.system(), db.vendored(), strategy))?;

        // This must be called before `from_metadata`, or the `SearchPath` root
        // will take precedence over the `Project` root, resulting in
        // all project files having HIGH durability.
        project_metadata.try_add_project_root(&db);

        let (settings, mut settings_diagnostics) = strategy
            .map_err(merged_options.to_settings(&db, strategy), |error| {
                anyhow::anyhow!("{}", error.pretty(&db))
            })?;
        settings_diagnostics.extend(
            program_settings_diagnostics
                .into_iter()
                .map(|diagnostic| diagnostic.into_diagnostic(&db)),
        );

        db.project = Some(Project::from_metadata(
            &db,
            project_metadata,
            settings,
            program_settings,
            settings_diagnostics,
        ));

        Ok(db)
    }

View on GitHub (pinned to 672bb4edf0)

Solutions

  1. Read the pretty message — it identifies the exact file, key, and violation; fix that key first
  2. Correct or delete the flagged option in pyproject.toml [tool.ty] / ty.toml / user-level config
  3. Re-run `ty check` in the project root to confirm the config now parses
  4. Compare your settings against the ty version's documentation; drop options that don't exist in that version

Example fix

# before — pyproject.toml
[tool.ty]
sourse = ["src"]  # typo: unknown option -> ProjectDatabase::new fails

# after
[tool.ty]
src = ["src"]
Defensive patterns

Strategy: try-catch

Try / catch

// Rust embedder: capture the pretty config diagnostic at construction
match ProjectDatabase::new(metadata, system, &strategy) {
    Ok(db) => { /* proceed */ }
    Err(err) => {
        // err already contains error.pretty(&db): file + setting + reason
        eprintln!("ty project setup failed:\n{err:#}");
        return;
    }
}

Prevention

When it happens

Trigger: Calling ProjectDatabase::new (or `ty check` on a project) where pyproject.toml [tool.ty] or ty.toml contains an unknown option key, a value of the wrong type, or an option invalid for the resolved environment; the error comes from merged_options.to_settings(&db, strategy) via strategy.map_err.

Common situations: Typos in setting names (e.g. `sourse` instead of `src`), copy-pasting ruff options into [tool.ty], using options added in a newer ty version, wrong TOML types (string where a list is expected), or a stale config after upgrading/downgrading ty.

Related errors


AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16). Data as JSON: /api/errors/2f00c6280e5aea25. Report an issue: GitHub.