Overview
Theupdate_claw.sh script safely updates OpenClaw to the latest version while:
- Preserving your existing configuration
- Maintaining service setup
- Re-applying critical Android patches that get overwritten during updates
Why This Script Exists
When you runnpm install -g openclaw@latest, npm:
- Downloads fresh code from the registry
- Overwrites
$PREFIX/lib/node_modules/openclaw/ - Destroys the
/tmppath patches applied during setup
Update Process
The script performs 4 sequential operations:Step-by-Step Breakdown
1. Stop the Service
- Prevents file conflicts while npm replaces running code
- Ensures clean shutdown of active connections
- Avoids corrupted state during the update
- Sends SIGTERM to the
openclaw gatewayprocess - Waits for graceful shutdown
- Marks the service as “down” in runit
2. Fetch Latest Version
- npm queries the registry for the latest version
- Downloads the package tarball
- Replaces
$PREFIX/lib/node_modules/openclaw/entirely - Recompiles any native dependencies
- Updates the
openclawbinary in$PREFIX/bin
This step can take 3-8 minutes depending on the size of the update and your device performance.
3. Re-apply the Critical Patch
The Problem: npm just overwroteentry.js with code that has hardcoded /tmp/openclaw paths.
The Solution:
- Locates the main entry point in the updated installation
- Replaces all occurrences of
/tmp/openclawwith$PREFIX/tmp/openclaw - Validates the patch was successful
This is the most critical step. Without it, OpenClaw will crash on startup with errors like:
4. Restart the Service
- Tells runit to start supervising the service again
- Executes
$PREFIX/var/service/openclaw/run - Begins logging to
$PREFIX/var/log/openclaw/current
Usage
Running the Update
Make sure the script is executable:
Expected Output
When to Run Updates
Recommended Schedule
- Weekly: Check for updates if you’re using cutting-edge features
- Monthly: Standard maintenance schedule
- As needed: When specific bugs are fixed or features are added
Checking for Available Updates
Before running the update script, check if a new version is available:Why Patches Must Be Re-applied
The Root Cause
OpenClaw is developed on traditional Linux systems where/tmp is a standard directory. The compiled code in dist/entry.js contains these hardcoded paths.
Why npm Doesn’t Preserve Patches
When you runnpm install -g openclaw@latest:
- npm completely replaces the
node_modules/openclaw/directory - Your previous modifications (the
sedpatches) are deleted - Fresh code with
/tmppaths is restored
The Android Reality
Android’s security model doesn’t allow apps to access/tmp. Termux provides:
$PREFIX/tmp→/data/data/com.termux/files/usr/tmp
This limitation affects all Node.js applications on Android, not just OpenClaw. Any app expecting
/tmp needs similar patching.Troubleshooting
Update fails during npm install
Possible causes:- Network timeout
- Insufficient storage
- Corrupted npm cache
Patch warning: “entry.js not found”
The package structure may have changed in a new version. Diagnosis:Service won’t start after update
Check logs:“ENOENT: no such file or directory, open ‘/tmp/openclaw/…’”
The patch didn’t apply. Manually run:“Error: Cannot find module…”
Dependencies may be broken. Reinstall:Service keeps restarting
Check for crashes:Configuration was reset
OpenClaw stores configuration in:openclaw onboard again.
Advanced: Manual Update Process
If you need to update without the script:Related Pages
- Setup Script - Initial installation and Android workarounds
- Service Management - Managing the OpenClaw service
- Environment Fixes - Understanding environment configuration