From f2acd816ebe82d442feb66b8c0e6ca5681ded688 Mon Sep 17 00:00:00 2001 From: Icy-Cat Date: Fri, 15 May 2026 11:49:40 +0800 Subject: [PATCH] fix(init): show config.json path in auto-detect error When auto_detect_db_dir() fails, the error told the user to edit config.json without saying where that file lives. On Windows that is %USERPROFILE%\.wx-cli\config.json, which is non-obvious. Use the config_path already computed at the top of cmd_init() so the error message includes the absolute path, plus a concrete example of the db_dir shape. --- src/cli/init.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cli/init.rs b/src/cli/init.rs index 5b8ce8f..ba406ab 100644 --- a/src/cli/init.rs +++ b/src/cli/init.rs @@ -35,8 +35,13 @@ pub fn cmd_init(force: bool) -> Result<()> { // Step 1: 检测 db_dir println!("检测微信数据目录..."); - let db_dir = config::auto_detect_db_dir() - .context("未能自动检测到微信数据目录\n请手动编辑 config.json 中的 db_dir 字段")?; + let db_dir = config::auto_detect_db_dir().with_context(|| format!( + "未能自动检测到微信数据目录\n\ + 请编辑配置文件并填写 db_dir 字段:\n \ + {}\n\ + (文件不存在则首次保存后自动创建;db_dir 示例: \\xwechat_files\\\\db_storage)", + config_path.display() + ))?; println!("找到数据目录: {}", db_dir.display()); // Step 2: 扫描密钥(需要 root/sudo)