Skip to content

Config: leading ~ in data_dir is taken literally #79

@melonkernel

Description

@melonkernel

Problem

A data_dir written with a leading ~ (e.g. data_dir = "~/anchor-data" in anchor.toml, or ANCHOR_DATA_DIR=~/x, or --data-dir ~/x) is parsed into a literal Path with no expansion. The ~ becomes a real folder name, so anchor creates ./~/... inside the project and reads from the wrong place; anchor list returns [] with no warning.

Expected

~ expands to $HOME (and $VAR is honored) from every config source.

Fix

@field_validator("data_dir") in src/anchor/infra/config.py runs expandvars + expanduser on the value, so every source (toml / env / --data-dir / constructor) funnels through one expansion. Regression tests in tests/infra/test_config_discovery.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cli`anchor` command-line surfacetype:bugSomething is broken or behaves unexpectedly

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions