From 46c9827e8ac8c4dde81c774f4d848ba3476ad077 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Thu, 6 Aug 2026 22:08:06 +0200 Subject: [PATCH] [fix](trx-config): keep the generated example off the machine that made it The example is generated from the config defaults, and [decode_logs].dir defaults to the running user's cache directory. So the file rendered /Users/sjg/Library/Caches/trx-rs/decoders on the machine that generated it and /root/.cache/trx-rs/decoders in CI, and the up-to-date test failed for everyone but its author. Pin dir to an illustrative /var/lib/trx-rs/decoders in the example config; omitting the key still falls back to the per-user directory. A new test asserts the rendered example contains none of this machine's home, cache or config directories, so the next environment-derived default cannot slip through the same way. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01SyX26FCpMQxiBoC7r5K1A7 Signed-off-by: Stan Grams --- src/trx-config/src/example.rs | 22 +++++++++++++++++++++- src/trx-config/src/server.rs | 9 ++++++++- trx-rs.toml.example | 3 ++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/trx-config/src/example.rs b/src/trx-config/src/example.rs index f61c22fd..9fa3eab5 100644 --- a/src/trx-config/src/example.rs +++ b/src/trx-config/src/example.rs @@ -63,7 +63,8 @@ const SECTION_COMMENTS: &[(&str, &str)] = &[ ( "trx-server.decoders", "Which decoders run. Trimming this list saves real CPU on small boxes.\n\ - Valid names: aprs, aprs_hf, ais, cw, ft2, ft4, ft8, lrpt, sstv, vdes, wefax, wspr.", + Valid names: aprs, aprs_hf, ais, cw, ft2, ft4, ft8, lrpt, sstv, vdes, wefax, wspr.\n\ + output_dir sets where sstv/wefax/lrpt write images (default: user cache dir).", ), ( "trx-server.pskreporter", @@ -232,6 +233,25 @@ mod tests { ); } + /// Nothing in the example may be derived from the machine that generated + /// it: [decode_logs].dir defaults to the running user's cache directory, + /// which made the generated file differ between a developer's laptop and + /// CI, and the up-to-date test fail for everyone but its author. + #[test] + fn test_example_has_no_machine_specific_paths() { + let example = combined_example(); + for dir in [dirs::home_dir(), dirs::cache_dir(), dirs::config_dir()] + .into_iter() + .flatten() + { + let dir = dir.to_string_lossy().into_owned(); + assert!( + !example.contains(&dir), + "the example contains this machine's {dir}; pin the value in example_config()" + ); + } + } + #[test] fn test_example_loads_and_validates() { let mut file = tempfile::NamedTempFile::new().unwrap(); diff --git a/src/trx-config/src/server.rs b/src/trx-config/src/server.rs index 7c6f233c..10595c51 100644 --- a/src/trx-config/src/server.rs +++ b/src/trx-config/src/server.rs @@ -755,7 +755,14 @@ impl ServerConfig { audio: AudioConfig::default(), pskreporter: PskReporterConfig::default(), aprsfi: AprsFiConfig::default(), - decode_logs: DecodeLogsConfig::default(), + decode_logs: DecodeLogsConfig { + // Pinned rather than defaulted: the default is derived from the + // running user's cache directory, which would make the generated + // example differ from machine to machine. Omitting the key + // falls back to that per-user directory. + dir: "/var/lib/trx-rs/decoders".to_string(), + ..DecodeLogsConfig::default() + }, decoders: DecodersConfig::default(), sdr: SdrConfig::default(), timeouts: TimeoutsConfig::default(), diff --git a/trx-rs.toml.example b/trx-rs.toml.example index 9f552ee7..cd2c1f4d 100644 --- a/trx-rs.toml.example +++ b/trx-rs.toml.example @@ -86,7 +86,7 @@ beacon_symbol_code = "-" # Write decodes to JSON Lines files. [trx-server.decode_logs] enabled = false -dir = "/Users/sjg/Library/Caches/trx-rs/decoders" +dir = "/var/lib/trx-rs/decoders" aprs_file = "TRXRS-APRS-%YYYY%-%MM%-%DD%.log" cw_file = "TRXRS-CW-%YYYY%-%MM%-%DD%.log" ft8_file = "TRXRS-FT8-%YYYY%-%MM%-%DD%.log" @@ -95,6 +95,7 @@ wefax_file = "TRXRS-WEFAX-%YYYY%-%MM%-%DD%.log" # Which decoders run. Trimming this list saves real CPU on small boxes. # Valid names: aprs, aprs_hf, ais, cw, ft2, ft4, ft8, lrpt, sstv, vdes, wefax, wspr. +# output_dir sets where sstv/wefax/lrpt write images (default: user cache dir). [trx-server.decoders] enabled = [ "aprs",