Repository navigation
Description
Goal
Allow operators to start torrust-tracker with an explicit configuration-file path, for example torrust-tracker --config-toml-path /etc/torrust/tracker/tracker.toml, without relying on a process environment variable.
Background
The tracker executable currently obtains its configuration through TORRUST_TRACKER_CONFIG_TOML, TORRUST_TRACKER_CONFIG_TOML_PATH, or the default development file. An explicit argument makes configuration selection visible at the executable boundary and allows native child-process tests to use isolated configuration without environment-source injection.
This is independent of closed EPIC #1978. That EPIC changed the configuration schema; this issue changes executable bootstrap source selection.
Required precedence
Base sources are mutually exclusive; only the winning source is used and the others are not merged. Per-value overrides are then merged on top of the selected base source.
TORRUST_TRACKER_CONFIG_OVERRIDE_<PATH>per-value overrides--config-toml-path <PATH>/-c <PATH>TORRUST_TRACKER_CONFIG_TOMLcomplete TOML contentTORRUST_TRACKER_CONFIG_TOML_PATHTOML file- Bootstrap default development file
- Rust schema defaults for non-mandatory values
Without the argument, the current behavior remains: complete TOML content beats an environment-selected file, which beats the default file. Overrides must continue to win over a CLI-selected file.
Scope
- Add
-c/--config-toml-path <PATH>to the main executable using the existingclapdependency, without clap'senvattribute. - Pass typed source selection through binary, application, bootstrap, and configuration layers without mutating process environment variables.
- Resolve a CLI path exactly from the current working directory; do not search parent directories.
- Treat an absent or empty argument value as a descriptive usage error with exit code
2. - Treat missing, unreadable, non-file, or invalid-TOML CLI sources as descriptive startup errors with exit code
1and no listener started. - Retain current
TORRUST_TRACKER_CONFIG_TOML_PATHmissing-file and parent-directory-search behavior for compatibility; document the intentional distinction. - Add configuration, executable-boundary, and manual verification coverage, including two concurrent child processes with isolated CLI paths, storage, and port-zero bindings.
Acceptance criteria
torrust-trackeraccepts-cand--config-toml-path <PATH>.- All eight combinations of CLI path, complete TOML environment source, and environment path select the required base source.
- Overrides replace matching values for every selected base source.
- Existing environment-only behavior is unchanged.
- Invalid CLI input returns the specified descriptive error and exit code, without starting listeners.
- Relative CLI paths cannot load a same-named file from a parent directory.
- Relevant tests and
linter allpass; manual precedence, override, invalid-source, and parallel-child scenarios are recorded.
Design constraints
- Keep CLI parsing separate from the configuration package; no environment reads in the parser.
- Preserve
app::start()as the compatibility wrapper for current callers and add a parameterized entry point as needed. - Preserve secret redaction; do not log TOML contents or secrets.
- Follow
docs/adrs/20260519000000_define_global_cli_output_contract.mdfor output channels and exit codes as far as this work touches them. Full migration of existing output behavior remains separate work.
Specification
The reviewed implementation plan, ownership/lifetime invariants, risks, acceptance verification table, and mandatory manual scenarios are tracked in docs/issues/open/<issue-number>-add-tracker-config-path-argument/ISSUE.md after the issue number is assigned.
Activity
docs(issues): add issue specification for torrust#2151
Merge #2153: docs(issues): add specification for #2151
test(configuration): cover source selection baseline for torrust#2151
refactor(configuration): add explicit file source for torrust#2151
docs(issues): preserve torrust#2151 manual verifier
docs(issues): rename torrust#2151 CLI verifier
docs(issues): plan Rust coverage for torrust#2151
docs(issues): refine torrust#2151 Rust test plan
docs(issues): plan verification-type guidance for AI agents
docs(testing): define automatic, manual, and disposable verification
Merge torrust#2178: feat(configuration): [torrust#2151] add tracker c…
Merge #2189: test(integration): [#1419] use explicit config path fixt…
chore(issues): archive closed issue specs torrust#1586, torrust#1588, t…
chore(issues): archive closed issue specs torrust#1586, torrust#1588, t…
Merge #2207: chore(issues): archive closed issue specifications