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
- Create the configured directory: mkdir -p <work_dir>
- Fix config.work_dir to point to an existing directory (verify with ls)
- 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
- Create the work_dir with create_dir_all at app startup
- Validate configured paths in the settings UI before saving
- Avoid configuring work_dir to a removable/network path that may vanish
- Prefer empty work_dir (CWD fallback) only when launch CWD is stable
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
- 当前 Codex 配置使用外部 model_catalog_json,无法同时应用每模型窗口、自动压缩或元数据
- 供应商配置总开关已关闭,未写入 config.toml / auth.json。
- 请先扫码登录微信
- 工作目录不存在:
- failed to allocate a stale Dream Skin backup path
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)