紧急修复:mode 字段位置错误导致 Gateway 无法启动 (v0.4.6)

根因:openclaw.json 的 mode 属于 gateway 对象内部,不是顶层字段。
OpenClaw zod-schema 对顶层 mode 报 Unrecognized key 错误。

修复:
- config.rs init_openclaw_config: mode 移入 gateway 对象
- dev-api.js init_openclaw_config: 同上
- dashboard.js 自愈: config.mode → config.gateway.mode
- dashboard.js 自愈: 自动删除旧版错误的顶层 mode 字段
- setup.js 安装流程: config.mode → config.gateway.mode
This commit is contained in:
晴天
2026-03-05 23:41:55 +08:00
parent 8ba25a25e0
commit b4e959ec99
12 changed files with 175 additions and 39 deletions

View File

@@ -35,7 +35,7 @@ pub fn enhanced_path() -> String {
})
.flatten();
#[cfg(not(target_os = "windows"))]
#[cfg(target_os = "macos")]
{
let mut extra: Vec<String> = vec![
"/usr/local/bin".into(),
@@ -69,6 +69,58 @@ pub fn enhanced_path() -> String {
parts.join(":")
}
#[cfg(target_os = "linux")]
{
let mut extra: Vec<String> = vec![
"/usr/local/bin".into(),
"/usr/bin".into(),
"/snap/bin".into(),
format!("{}/.local/bin", home.display()),
format!("{}/.nvm/current/bin", home.display()),
format!("{}/.volta/bin", home.display()),
format!("{}/.nodenv/shims", home.display()),
format!("{}/.fnm/current/bin", home.display()),
format!("{}/n/bin", home.display()),
];
// NVM_DIR 环境变量(用户可能自定义了 nvm 安装目录)
let nvm_dir = std::env::var("NVM_DIR")
.ok()
.map(std::path::PathBuf::from)
.unwrap_or_else(|| home.join(".nvm"));
let nvm_versions = nvm_dir.join("versions/node");
if nvm_versions.is_dir() {
if let Ok(entries) = std::fs::read_dir(&nvm_versions) {
for entry in entries.flatten() {
let bin = entry.path().join("bin");
if bin.is_dir() {
extra.push(bin.to_string_lossy().to_string());
}
}
}
}
// nodesource / 手动安装的 Node.js 可能在 /usr/local/lib/nodejs/ 下
let nodejs_lib = std::path::Path::new("/usr/local/lib/nodejs");
if nodejs_lib.is_dir() {
if let Ok(entries) = std::fs::read_dir(nodejs_lib) {
for entry in entries.flatten() {
let bin = entry.path().join("bin");
if bin.is_dir() {
extra.push(bin.to_string_lossy().to_string());
}
}
}
}
let mut parts: Vec<&str> = vec![];
if let Some(ref cp) = custom_path {
parts.push(cp.as_str());
}
parts.extend(extra.iter().map(|s| s.as_str()));
if !current.is_empty() {
parts.push(&current);
}
parts.join(":")
}
#[cfg(target_os = "windows")]
{
let pf = std::env::var("ProgramFiles").unwrap_or_else(|_| r"C:\Program Files".into());