From b6ba958b79a5356716b89381bcad46378a9835d6 Mon Sep 17 00:00:00 2001 From: hfshfg <38004547@qq.com> Date: Fri, 1 May 2026 15:36:34 +0800 Subject: [PATCH] fix(portable): node-extract path + unreachable legacy-config sync Two real bugs in the portable launchers: 1. Windows-Install.bat: xcopy reads from %TEMP%\node--win-x64 but Expand-Archive extracts into %TEMP%\node-extract\node--win-x64. Result: empty runtime\node-win-x64\ on networked install path. 2. Mac-Start.command + Windows-Start.bat: legacy-config sync block was placed AFTER the default-config block, so the "config.json exists but openclaw.json doesn't" branch was unreachable. Existing USB users with config.json never got their settings migrated; they got the empty default instead. Reordered so legacy migration runs first, default only as fallback. Co-Authored-By: Claude Opus 4.7 (1M context) --- portable/Mac-Start.command | 17 +++++++++-------- portable/Windows-Install.bat | 2 +- portable/Windows-Start.bat | 19 ++++++++++--------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/portable/Mac-Start.command b/portable/Mac-Start.command index 0f635be..6c0ce05 100755 --- a/portable/Mac-Start.command +++ b/portable/Mac-Start.command @@ -72,8 +72,13 @@ mkdir -p "$STATE_DIR" "$DATA_DIR/memory" "$DATA_DIR/backups" "$DATA_DIR/logs" # ---- 5. Default config ---- if [ ! -f "$CONFIG_FILE" ]; then - echo -e " ${YELLOW}First run - creating default config...${NC}" - cat > "$CONFIG_FILE" << 'CFGEOF' + if [ -f "$DATA_DIR/config.json" ]; then + echo -e " ${YELLOW}Migrating legacy config...${NC}" + cp "$DATA_DIR/config.json" "$CONFIG_FILE" + echo -e " ${GREEN}Config migrated${NC}" + else + echo -e " ${YELLOW}First run - creating default config...${NC}" + cat > "$CONFIG_FILE" << 'CFGEOF' { "gateway": { "mode": "local", @@ -81,15 +86,11 @@ if [ ! -f "$CONFIG_FILE" ]; then } } CFGEOF - echo -e " ${GREEN}Config created${NC}" + echo -e " ${GREEN}Config created${NC}" + fi echo "" fi -# Sync config from legacy location -if [ -f "$DATA_DIR/config.json" ] && [ ! -f "$CONFIG_FILE" ]; then - cp "$DATA_DIR/config.json" "$CONFIG_FILE" -fi - # ---- 6. Set environment (portable mode) ---- export OPENCLAW_HOME="$DATA_DIR" export OPENCLAW_STATE_DIR="$STATE_DIR" diff --git a/portable/Windows-Install.bat b/portable/Windows-Install.bat index 3734c7b..37d2be7 100644 --- a/portable/Windows-Install.bat +++ b/portable/Windows-Install.bat @@ -115,7 +115,7 @@ if "!USE_NODE!"=="usb" ( echo 解压中... mkdir "%INSTALL_TARGET%\runtime\node-win-x64" 2>nul powershell -command "Expand-Archive -Path '%TEMP%\!NODE_ZIP!' -DestinationPath '%TEMP%\node-extract' -Force" - xcopy /s /e /q /y "%TEMP%\node-%NODE_VER%-win-x64\*" "%INSTALL_TARGET%\runtime\node-win-x64\" >nul + xcopy /s /e /q /y "%TEMP%\node-extract\node-%NODE_VER%-win-x64\*" "%INSTALL_TARGET%\runtime\node-win-x64\" >nul rmdir /s /q "%TEMP%\node-extract" 2>nul del "%TEMP%\!NODE_ZIP!" 2>nul diff --git a/portable/Windows-Start.bat b/portable/Windows-Start.bat index dd733ad..3dad924 100644 --- a/portable/Windows-Start.bat +++ b/portable/Windows-Start.bat @@ -46,19 +46,20 @@ if not exist "%DATA_DIR%\memory" mkdir "%DATA_DIR%\memory" if not exist "%DATA_DIR%\backups" mkdir "%DATA_DIR%\backups" if not exist "%DATA_DIR%\logs" mkdir "%DATA_DIR%\logs" -REM Default config +REM Default config (migrate legacy if present, otherwise create) if not exist "%STATE_DIR%\openclaw.json" ( - echo First run - creating default config... - (echo {"gateway":{"mode":"local","auth":{"token":"uclaw"}}})>"%STATE_DIR%\openclaw.json" - echo Config created + if exist "%DATA_DIR%\config.json" ( + echo Migrating legacy config... + copy "%DATA_DIR%\config.json" "%STATE_DIR%\openclaw.json" >nul + echo Config migrated + ) else ( + echo First run - creating default config... + (echo {"gateway":{"mode":"local","auth":{"token":"uclaw"}}})>"%STATE_DIR%\openclaw.json" + echo Config created + ) echo. ) -REM Sync config from legacy location -if exist "%DATA_DIR%\config.json" if not exist "%STATE_DIR%\openclaw.json" ( - copy "%DATA_DIR%\config.json" "%STATE_DIR%\openclaw.json" >nul -) - REM Check dependencies if not exist "%CORE_DIR%\node_modules" ( echo First run - installing dependencies...