BigPizzaV3/CodexPlusPlus · error · anyhow::Error
工作目录不存在:{}
Error message
工作目录不存在:{} What it means
The working directory passed to the Codex app-server, config.work_dir or the process cwd when empty, does not exist as a directory, so the connector aborts before spawning anything. The app-server would otherwise run in a bogus cwd and fail later in worse ways.
Source
Thrown at crates/codex-plus-core/src/connect/mod.rs:119
pub type SharedWeixinConnectStatus = Arc<Mutex<WeixinConnectStatus>>;
pub async fn run_weixin_connect(
config: WeixinConnectConfig,
stop: Arc<AtomicBool>,
status: SharedWeixinConnectStatus,
) -> 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 app_config = AppServerConfig {
executable: config.codex_path.clone(),
work_dir,
model: config.model.clone(),
sandbox: config.sandbox.clone(),
};View on GitHub (pinned to f2074595a2)
Solutions
- Create the directory or point work_dir at an existing one
- Store an absolute path and expand tilde or env vars before saving the profile
- When work_dir is empty by design, start the process from a valid cwd
- Fix typos in the saved profile path
Example fix
// before
run_weixin_connect(config, stop, status).await?;
// after: validate or create the directory before starting
let dir = std::path::PathBuf::from(&config.work_dir);
if !dir.is_dir() { std::fs::create_dir_all(&dir)?; }
run_weixin_connect(config, stop, status).await?; Defensive patterns
Strategy: validation
Validate before calling
let dir = std::path::Path::new(config.work_dir.trim());
if config.work_dir.trim().is_empty() || !dir.is_dir() {
bail!("work dir missing: {}", dir.display());
} Prevention
- Expand tilde and env vars before saving work_dir
- Use absolute paths in profiles
- Create the directory with create_dir_all when it is owned by the app
When it happens
Trigger: WeixinConnectConfig.work_dir points at a deleted or renamed directory; a relative path resolved against a different cwd; an unexpanded tilde or env var left in the saved path; empty work_dir while the daemon cwd itself was removed.
Common situations: Project moved or deleted after the profile was saved; service started from a different directory; the volume holding the directory is not mounted.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23).
Data as JSON: /api/errors/e99bba071c9ab538.
Report an issue: GitHub.