BigPizzaV3/CodexPlusPlus · error

工作目录不存在:

Error message

工作目录不存在:{work_dir}

What it means

The WeChat connect flow resolves its working directory from config.work_dir, falling back to the current process directory, and validates that the path is an existing directory before spawning anything. When the path is missing or is a file, it bails with this message including the resolved path. This prevents the bridge from creating state in unexpected or nonexistent locations.

Solutions

  1. Create the configured directory: mkdir -p <work_dir>
  2. Fix config.work_dir to point to an existing directory (verify with ls)
  3. Clear work_dir to empty so the process current directory is used instead

Example fix

// before
config.work_dir = "/home/user/codex-state"; // directory deleted
run_weixin_connect(config).await?;
// after
std::fs::create_dir_all("/home/user/codex-state")?; // ensure it exists
config.work_dir = "/home/user/codex-state";
run_weixin_connect(config).await?;
Defensive patterns

Strategy: validation

Validate before calling

let wd = if config.work_dir.is_empty() { std::env::current_dir()? } else { PathBuf::from(&config.work_dir) };
if !wd.is_dir() { std::fs::create_dir_all(&wd)?; }

Type guard

fn work_dir_exists(c: &WeixinConfig) -> bool {
    let p = if c.work_dir.is_empty() { std::env::current_dir().unwrap_or_default() } else { PathBuf::from(&c.work_dir) };
    p.is_dir()
}

Try / catch

match run_weixin_connect(config).await {
    Err(e) if e.to_string().contains("工作目录不存在") => { create_dir_and_retry()?; }
    other => other,
}

Prevention

When it happens

Trigger: Calling run_weixin_connect with a WeixinConfig whose `work_dir` points to a path that does not exist or is not a directory (after fallback to std::env::current_dir() when work_dir is empty).

Common situations: Typo in the configured work_dir path; directory deleted after being configured; work_dir points to a file; the fallback CWD was removed (process started in a deleted directory).

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/0a323b94d5030028. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/connect/mod.rs:152

}

pub async fn run_weixin_connect_with_codex_path(
    config: WeixinConnectConfig,
    stop: Arc<AtomicBool>,
    status: SharedWeixinConnectStatus,
    codex_path: WeixinCodexPath,
) -> anyhow::Result<()> {
    let config = config.normalized();
    if config.token.is_empty() {
        bail!("请先扫码登录微信");
    }
    let work_dir = if config.work_dir.is_empty() {
        std::env::current_dir().context("无法读取当前工作目录")?
    } else {
        PathBuf::from(&config.work_dir)
    };
    if !work_dir.is_dir() {
        bail!("工作目录不存在:{}", work_dir.display());
    }

    update_status(&status, |current| {
        current.state = "starting".to_string();
        current.message = "正在连接微信和 Codex app-server...".to_string();
        current.account_id = config.account_id.clone();
        current.has_token = true;
    });

    let client = WeixinClient::new(&config.base_url, &config.token, &config.route_tag)?;
    let store = ConnectSessionStore::default_for_account(&config.account_id);
    let mut state = store.load().unwrap_or_default();
    let mut app_config = AppServerConfig {
        executable: config.codex_path.clone(),
        work_dir,
        model: config.model.clone(),
        sandbox: config.sandbox.clone(),
    };

View on GitHub (pinned to b1ed92e5e4)