Skip to content

Commit aada5d0

Browse files
committed
fix: save npm install error log to ~/clawrouter-npm-install.log
Previously the log file used a temp path that users couldn't find, and the error output was easy to miss. Now saves to home directory with clear messaging to send the log for debugging.
1 parent 61f0e3d commit aada5d0

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

scripts/update.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,20 @@ restore_previous_install() {
5151

5252
run_dependency_install() {
5353
local plugin_dir="$1"
54-
local log_file
55-
log_file="$(mktemp -t clawrouter-update-npm.XXXXXX.log)"
54+
local log_file="$HOME/clawrouter-npm-install.log"
5655

56+
echo " (log: $log_file)"
5757
if (cd "$plugin_dir" && npm install --omit=dev >"$log_file" 2>&1); then
5858
tail -1 "$log_file"
59-
rm -f "$log_file"
6059
else
61-
echo " npm install failed. Last 20 log lines:" >&2
62-
tail -20 "$log_file" >&2 || true
63-
echo " Full log: $log_file" >&2
60+
echo ""
61+
echo " ✗ npm install failed. Error log:"
62+
echo " ─────────────────────────────────"
63+
tail -30 "$log_file" >&2 || true
64+
echo " ─────────────────────────────────"
65+
echo ""
66+
echo " Full log saved: $log_file"
67+
echo " Send this file to @bc1max on Telegram for help."
6468
return 1
6569
fi
6670
}
@@ -218,6 +222,11 @@ const fs = require('fs');
218222
const path = require('path');
219223
const authDir = path.join(os.homedir(), '.openclaw', 'agents', 'main', 'agent');
220224
const authPath = path.join(authDir, 'auth-profiles.json');
225+
function atomicWrite(filePath, data) {
226+
const tmpPath = filePath + '.tmp.' + process.pid;
227+
fs.writeFileSync(tmpPath, data);
228+
fs.renameSync(tmpPath, filePath);
229+
}
221230
222231
fs.mkdirSync(authDir, { recursive: true });
223232
@@ -232,7 +241,7 @@ if (fs.existsSync(authPath)) {
232241
const profileKey = 'blockrun:default';
233242
if (!store.profiles[profileKey]) {
234243
store.profiles[profileKey] = { type: 'api_key', provider: 'blockrun', key: 'x402-proxy-handles-auth' };
235-
fs.writeFileSync(authPath, JSON.stringify(store, null, 2));
244+
atomicWrite(authPath, JSON.stringify(store, null, 2));
236245
console.log(' Auth profile created');
237246
} else {
238247
console.log(' Auth profile already exists');

0 commit comments

Comments
 (0)