astral-sh/ruff · error

truth source directory `{dir}` does not contain a base name

Error message

truth source directory `{dir}` does not contain a base name

What it means

`TaskSource::new` takes the fixture directory's `file_name()` as the source name; like error 74, `file_name()` is None only for root/dot paths. This is an internal invariant asserting the standard truth layout: every child of `truth/` must be a normally-named directory containing a `completion.toml`.

Source

Thrown at crates/ty_completion_eval/src/main.rs:432

            let dir = SystemPath::from_std_path(&path).ok_or_else(|| {
                anyhow::anyhow!(
                    "truth source directory `{path}` contains invalid UTF-8",
                    path = path.display()
                )
            })?;
            sources.push(TaskSource::new(dir)?);
        }
        // Sort our sources so that we always run in the same order.
        // And also so that the CSV output is deterministic across
        // all platforms.
        sources.sort_by(|source1, source2| source1.name.cmp(&source2.name));
        Ok(sources)
    }

    fn new(dir: &SystemPath) -> anyhow::Result<TaskSource> {
        let name = dir.file_name().ok_or_else(|| {
            anyhow::anyhow!("truth source directory `{dir}` does not contain a base name")
        })?;

        let truth_path = dir.join("completion.toml");
        let truth_data = std::fs::read(truth_path.as_std_path())
            .with_context(|| format!("failed to read truth data at `{truth_path}`"))?;
        let truth = toml::from_slice(&truth_data).with_context(|| {
            format!("failed to parse TOML completion truth data from `{truth_path}`")
        })?;

        Ok(TaskSource {
            dir: dir.to_path_buf(),
            name: name.to_string(),
            truth,
        })
    }

    /// Convert this "source" task (from the Ruff repository) into
    /// one or more evaluation tasks within a single Python project.

View on GitHub (pinned to 672bb4edf0)

Solutions

  1. Keep the standard layout: `truth/<fixture-name>/completion.toml` plus source files
  2. If hit with an unmodified checkout, report upstream with the exact command and tree
Defensive patterns

Strategy: validation

Validate before calling

for d in crates/ty_completion_eval/truth/*/; do
  [ -f "${d}completion.toml" ] || echo "fixture missing completion.toml: $d" >&2
done

Prevention

When it happens

Trigger: A truth tree where an enumerated child directory resolves to a degenerate path (root or `..`-terminated); practically only reachable via a tampered or script-generated truth layout or a harness bug.

Common situations: Automated scripts writing fixtures into unusual locations; refactors of the truth enumeration code.

Related errors


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