claude-code-termux 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +198 -0
- package/bin/claude-termux.js +80 -0
- package/docs/INSTALLATION.md +136 -0
- package/docs/KNOWN-ISSUES.md +135 -0
- package/docs/TROUBLESHOOTING.md +225 -0
- package/package.json +50 -0
- package/postinstall.js +204 -0
- package/scripts/download-ripgrep.sh +55 -0
- package/scripts/setup-termux.sh +120 -0
- package/scripts/verify-install.js +188 -0
- package/src/binaries/README.md +29 -0
- package/src/patches/apply-all.js +45 -0
- package/src/patches/hook-events.js +108 -0
- package/src/patches/oauth-storage.js +163 -0
- package/src/patches/path-normalization.js +134 -0
- package/src/patches/ripgrep-fallback.js +95 -0
- package/src/patches/sharp-fallback.js +65 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Troubleshooting Guide
|
|
2
|
+
|
|
3
|
+
This guide helps you resolve common issues with Claude Code on Termux.
|
|
4
|
+
|
|
5
|
+
## Common Issues
|
|
6
|
+
|
|
7
|
+
### 1. Sharp Module Error
|
|
8
|
+
|
|
9
|
+
**Error:**
|
|
10
|
+
```
|
|
11
|
+
Error: Could not load the "sharp" module using the android-arm64 runtime
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**Cause:** The Sharp image library doesn't have native binaries for Android ARM64.
|
|
15
|
+
|
|
16
|
+
**Solution:**
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g @img/sharp-wasm32 --force
|
|
19
|
+
npm install -g sharp --force
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The `--force` flag is needed to override the native binary with the WebAssembly version.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
### 2. Ripgrep Binary Not Found
|
|
27
|
+
|
|
28
|
+
**Error:**
|
|
29
|
+
```
|
|
30
|
+
Error: spawn /data/data/com.termux/files/usr/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-android/rg ENOENT
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Cause:** Claude Code ships with platform-specific ripgrep binaries, but android-arm64 isn't included.
|
|
34
|
+
|
|
35
|
+
**Solution:**
|
|
36
|
+
```bash
|
|
37
|
+
pkg install ripgrep
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The wrapper will automatically use the system ripgrep.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### 3. Shell Not Found
|
|
45
|
+
|
|
46
|
+
**Error:**
|
|
47
|
+
```
|
|
48
|
+
Command failed: No suitable shell found. Claude CLI requires a Posix shell environment.
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Cause:** Claude Code has an allowlist of shell paths that doesn't include Termux's location.
|
|
52
|
+
|
|
53
|
+
**Solution:**
|
|
54
|
+
```bash
|
|
55
|
+
export SHELL=/data/data/com.termux/files/usr/bin/bash
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Add to ~/.bashrc for persistence:
|
|
59
|
+
```bash
|
|
60
|
+
echo 'export SHELL=/data/data/com.termux/files/usr/bin/bash' >> ~/.bashrc
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### 4. Memory Crash / Double Free
|
|
66
|
+
|
|
67
|
+
**Error:**
|
|
68
|
+
```
|
|
69
|
+
double free or corruption (out)
|
|
70
|
+
Aborted
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Cause:** Native binaries compiled for x86_64 running on ARM64, or Node.js version issues.
|
|
74
|
+
|
|
75
|
+
**Solutions:**
|
|
76
|
+
|
|
77
|
+
1. Upgrade Node.js:
|
|
78
|
+
```bash
|
|
79
|
+
pkg install nodejs-lts
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. Use an older Claude Code version:
|
|
83
|
+
```bash
|
|
84
|
+
npm install -g @anthropic-ai/claude-code@0.2.114
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
3. Ensure you have enough free memory (4GB+ recommended)
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### 5. OAuth Login Stuck
|
|
92
|
+
|
|
93
|
+
**Problem:** OAuth login appears to succeed but subsequent commands fail with authentication errors.
|
|
94
|
+
|
|
95
|
+
**Cause:** Token persistence issues with the system keychain on Android.
|
|
96
|
+
|
|
97
|
+
**Solution:** Use API key authentication instead:
|
|
98
|
+
```bash
|
|
99
|
+
export ANTHROPIC_API_KEY=your-api-key
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### 6. Custom Commands Not Loading
|
|
105
|
+
|
|
106
|
+
**Problem:** Commands in `~/.claude/commands/` are not discovered.
|
|
107
|
+
|
|
108
|
+
**Cause:** Path resolution issues with Termux's non-standard directory structure.
|
|
109
|
+
|
|
110
|
+
**Solution:**
|
|
111
|
+
|
|
112
|
+
1. Ensure the directory exists:
|
|
113
|
+
```bash
|
|
114
|
+
mkdir -p ~/.claude/commands
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
2. Create a test command:
|
|
118
|
+
```bash
|
|
119
|
+
cat > ~/.claude/commands/test.md << 'EOF'
|
|
120
|
+
# Test Command
|
|
121
|
+
Just respond with "Test command works!"
|
|
122
|
+
EOF
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
3. Set correct permissions:
|
|
126
|
+
```bash
|
|
127
|
+
chmod 755 ~/.claude ~/.claude/commands
|
|
128
|
+
chmod 644 ~/.claude/commands/*.md
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
4. Restart Claude Code
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### 7. Hooks Not Firing
|
|
136
|
+
|
|
137
|
+
**Problem:** PostToolUse hooks don't trigger, while other hooks work.
|
|
138
|
+
|
|
139
|
+
**Cause:** Event emission timing issues on Android.
|
|
140
|
+
|
|
141
|
+
**Solution:**
|
|
142
|
+
|
|
143
|
+
1. Enable hook debugging:
|
|
144
|
+
```bash
|
|
145
|
+
DEBUG_HOOKS=1 claude
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
2. Ensure your hook scripts are executable
|
|
149
|
+
3. Use absolute paths in hook commands
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### 8. Slow Performance
|
|
154
|
+
|
|
155
|
+
**Cause:** Mobile hardware limitations.
|
|
156
|
+
|
|
157
|
+
**Solutions:**
|
|
158
|
+
|
|
159
|
+
1. Close other apps to free memory
|
|
160
|
+
2. Use simpler prompts
|
|
161
|
+
3. Limit concurrent operations
|
|
162
|
+
4. Consider using SSH to a remote machine instead
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
### 9. npm Install Fails
|
|
167
|
+
|
|
168
|
+
**Error:** Various npm errors during installation.
|
|
169
|
+
|
|
170
|
+
**Solutions:**
|
|
171
|
+
|
|
172
|
+
1. Clear npm cache:
|
|
173
|
+
```bash
|
|
174
|
+
npm cache clean --force
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
2. Remove node_modules and reinstall:
|
|
178
|
+
```bash
|
|
179
|
+
rm -rf $(npm root -g)/claude-code-termux
|
|
180
|
+
npm install -g claude-code-termux
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
3. Check disk space:
|
|
184
|
+
```bash
|
|
185
|
+
df -h
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### 10. "Command not found: claude"
|
|
191
|
+
|
|
192
|
+
**Cause:** npm global bin directory not in PATH.
|
|
193
|
+
|
|
194
|
+
**Solution:**
|
|
195
|
+
```bash
|
|
196
|
+
export PATH=$PATH:$(npm config get prefix)/bin
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Add to ~/.bashrc for persistence.
|
|
200
|
+
|
|
201
|
+
## Debug Mode
|
|
202
|
+
|
|
203
|
+
Enable verbose output for troubleshooting:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
DEBUG=1 claude
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
For hook-specific debugging:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
DEBUG_HOOKS=1 claude
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Getting Help
|
|
216
|
+
|
|
217
|
+
1. Check [Known Issues](KNOWN-ISSUES.md)
|
|
218
|
+
2. Search [GitHub Issues](https://github.com/anthropics/claude-code/issues)
|
|
219
|
+
3. Report new issues with:
|
|
220
|
+
- Termux version
|
|
221
|
+
- Node.js version
|
|
222
|
+
- Android version
|
|
223
|
+
- Device model
|
|
224
|
+
- Error messages
|
|
225
|
+
- Steps to reproduce
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-code-termux",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Claude Code CLI with Termux/Android compatibility fixes - a wrapper that patches issues with Sharp, ripgrep, and path resolution on ARM64 Android",
|
|
5
|
+
"author": "Jimoh Ovbiagele <findingjimoh@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/findingjimoh/claude-cli-termux.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"claude",
|
|
13
|
+
"anthropic",
|
|
14
|
+
"ai",
|
|
15
|
+
"cli",
|
|
16
|
+
"termux",
|
|
17
|
+
"android",
|
|
18
|
+
"arm64",
|
|
19
|
+
"coding-assistant"
|
|
20
|
+
],
|
|
21
|
+
"bin": {
|
|
22
|
+
"claude": "./bin/claude-termux.js",
|
|
23
|
+
"claude-termux": "./bin/claude-termux.js"
|
|
24
|
+
},
|
|
25
|
+
"main": "./bin/claude-termux.js",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"postinstall": "node postinstall.js",
|
|
28
|
+
"test": "node scripts/verify-install.js"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@anthropic-ai/claude-code": "^2.1.3"
|
|
32
|
+
},
|
|
33
|
+
"optionalDependencies": {
|
|
34
|
+
"@img/sharp-wasm32": "^0.33.5"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18.0.0 <25.0.0"
|
|
38
|
+
},
|
|
39
|
+
"os": [
|
|
40
|
+
"android",
|
|
41
|
+
"linux",
|
|
42
|
+
"darwin",
|
|
43
|
+
"win32"
|
|
44
|
+
],
|
|
45
|
+
"cpu": [
|
|
46
|
+
"arm64",
|
|
47
|
+
"x64",
|
|
48
|
+
"arm"
|
|
49
|
+
]
|
|
50
|
+
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Claude Code Termux - Post-install Script
|
|
5
|
+
*
|
|
6
|
+
* This script runs after npm install to:
|
|
7
|
+
* 1. Detect if running on Termux/Android
|
|
8
|
+
* 2. Set up ripgrep binary for ARM64 Android
|
|
9
|
+
* 3. Ensure Sharp WASM fallback is configured
|
|
10
|
+
* 4. Create necessary directories and symlinks
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const { execSync } = require('child_process');
|
|
18
|
+
|
|
19
|
+
// Detect Termux environment
|
|
20
|
+
const isTermux = process.platform === 'android' ||
|
|
21
|
+
process.env.PREFIX?.includes('com.termux') ||
|
|
22
|
+
process.env.HOME?.includes('com.termux');
|
|
23
|
+
|
|
24
|
+
const isARM64 = process.arch === 'arm64';
|
|
25
|
+
|
|
26
|
+
console.log('[claude-code-termux] Post-install script running...');
|
|
27
|
+
console.log(`[claude-code-termux] Platform: ${process.platform}, Arch: ${process.arch}`);
|
|
28
|
+
console.log(`[claude-code-termux] Termux detected: ${isTermux}`);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Find the Claude Code installation directory
|
|
32
|
+
*/
|
|
33
|
+
function findClaudeCodePath() {
|
|
34
|
+
const possiblePaths = [
|
|
35
|
+
path.join(__dirname, 'node_modules', '@anthropic-ai', 'claude-code'),
|
|
36
|
+
path.join(__dirname, '..', '@anthropic-ai', 'claude-code'),
|
|
37
|
+
path.join(process.env.PREFIX || '/usr', 'lib', 'node_modules', '@anthropic-ai', 'claude-code'),
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
for (const p of possiblePaths) {
|
|
41
|
+
if (fs.existsSync(p)) {
|
|
42
|
+
return p;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Set up ripgrep for ARM64 Android
|
|
50
|
+
*/
|
|
51
|
+
function setupRipgrep(claudeCodePath) {
|
|
52
|
+
if (!isTermux || !isARM64) {
|
|
53
|
+
console.log('[claude-code-termux] Skipping ripgrep setup (not Termux ARM64)');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
console.log('[claude-code-termux] Setting up ripgrep for ARM64 Android...');
|
|
58
|
+
|
|
59
|
+
const vendorDir = path.join(claudeCodePath, 'vendor', 'ripgrep', 'arm64-android');
|
|
60
|
+
|
|
61
|
+
// Create directory if it doesn't exist
|
|
62
|
+
if (!fs.existsSync(vendorDir)) {
|
|
63
|
+
fs.mkdirSync(vendorDir, { recursive: true });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const targetBinary = path.join(vendorDir, 'rg');
|
|
67
|
+
|
|
68
|
+
// Check if we have a bundled binary
|
|
69
|
+
const bundledBinary = path.join(__dirname, 'src', 'binaries', 'rg');
|
|
70
|
+
if (fs.existsSync(bundledBinary)) {
|
|
71
|
+
console.log('[claude-code-termux] Using bundled ripgrep binary');
|
|
72
|
+
fs.copyFileSync(bundledBinary, targetBinary);
|
|
73
|
+
fs.chmodSync(targetBinary, 0o755);
|
|
74
|
+
console.log('[claude-code-termux] Ripgrep binary installed successfully');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Try to use system ripgrep from Termux
|
|
79
|
+
try {
|
|
80
|
+
const systemRg = execSync('which rg', { encoding: 'utf8' }).trim();
|
|
81
|
+
if (systemRg && fs.existsSync(systemRg)) {
|
|
82
|
+
console.log(`[claude-code-termux] Found system ripgrep at ${systemRg}`);
|
|
83
|
+
// Create symlink to system ripgrep
|
|
84
|
+
if (fs.existsSync(targetBinary)) {
|
|
85
|
+
fs.unlinkSync(targetBinary);
|
|
86
|
+
}
|
|
87
|
+
fs.symlinkSync(systemRg, targetBinary);
|
|
88
|
+
console.log('[claude-code-termux] Linked to system ripgrep');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
} catch (err) {
|
|
92
|
+
// System ripgrep not found
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Try to download ripgrep
|
|
96
|
+
console.log('[claude-code-termux] Attempting to download ripgrep...');
|
|
97
|
+
try {
|
|
98
|
+
// Use curl to download (available in Termux)
|
|
99
|
+
const rgUrl = 'https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-aarch64-unknown-linux-gnu.tar.gz';
|
|
100
|
+
const tmpDir = path.join(__dirname, 'tmp');
|
|
101
|
+
const tarFile = path.join(tmpDir, 'ripgrep.tar.gz');
|
|
102
|
+
|
|
103
|
+
if (!fs.existsSync(tmpDir)) {
|
|
104
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
execSync(`curl -sL "${rgUrl}" -o "${tarFile}"`, { stdio: 'inherit' });
|
|
108
|
+
execSync(`tar -xzf "${tarFile}" -C "${tmpDir}"`, { stdio: 'inherit' });
|
|
109
|
+
|
|
110
|
+
// Find the rg binary in extracted files
|
|
111
|
+
const extractedDir = fs.readdirSync(tmpDir).find(f => f.startsWith('ripgrep-'));
|
|
112
|
+
if (extractedDir) {
|
|
113
|
+
const extractedBinary = path.join(tmpDir, extractedDir, 'rg');
|
|
114
|
+
if (fs.existsSync(extractedBinary)) {
|
|
115
|
+
fs.copyFileSync(extractedBinary, targetBinary);
|
|
116
|
+
fs.chmodSync(targetBinary, 0o755);
|
|
117
|
+
console.log('[claude-code-termux] Ripgrep downloaded and installed successfully');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Cleanup
|
|
122
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
123
|
+
} catch (err) {
|
|
124
|
+
console.error('[claude-code-termux] Failed to download ripgrep:', err.message);
|
|
125
|
+
console.log('[claude-code-termux] Please install ripgrep manually: pkg install ripgrep');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Try to copy linux-arm64 binaries as android-arm64 fallback
|
|
131
|
+
*/
|
|
132
|
+
function copyLinuxBinariesAsAndroidFallback(claudeCodePath) {
|
|
133
|
+
if (!isTermux || !isARM64) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const vendorDir = path.join(claudeCodePath, 'vendor');
|
|
138
|
+
if (!fs.existsSync(vendorDir)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// List of tools that might have platform-specific binaries
|
|
143
|
+
const tools = ['ripgrep'];
|
|
144
|
+
|
|
145
|
+
for (const tool of tools) {
|
|
146
|
+
const linuxPath = path.join(vendorDir, tool, 'arm64-linux');
|
|
147
|
+
const androidPath = path.join(vendorDir, tool, 'arm64-android');
|
|
148
|
+
|
|
149
|
+
if (fs.existsSync(linuxPath) && !fs.existsSync(androidPath)) {
|
|
150
|
+
console.log(`[claude-code-termux] Copying ${tool} linux-arm64 as android-arm64 fallback`);
|
|
151
|
+
try {
|
|
152
|
+
fs.cpSync(linuxPath, androidPath, { recursive: true });
|
|
153
|
+
} catch (err) {
|
|
154
|
+
console.error(`[claude-code-termux] Failed to copy ${tool}:`, err.message);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Create OAuth token storage directory
|
|
162
|
+
*/
|
|
163
|
+
function setupOAuthStorage() {
|
|
164
|
+
const homeDir = process.env.HOME || '/data/data/com.termux/files/home';
|
|
165
|
+
const claudeDir = path.join(homeDir, '.claude');
|
|
166
|
+
|
|
167
|
+
if (!fs.existsSync(claudeDir)) {
|
|
168
|
+
fs.mkdirSync(claudeDir, { recursive: true, mode: 0o700 });
|
|
169
|
+
console.log('[claude-code-termux] Created .claude directory');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Main setup function
|
|
175
|
+
*/
|
|
176
|
+
function main() {
|
|
177
|
+
const claudeCodePath = findClaudeCodePath();
|
|
178
|
+
|
|
179
|
+
if (!claudeCodePath) {
|
|
180
|
+
console.log('[claude-code-termux] Claude Code not found yet (will be installed next)');
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
console.log(`[claude-code-termux] Found Claude Code at: ${claudeCodePath}`);
|
|
185
|
+
|
|
186
|
+
// Run setup tasks
|
|
187
|
+
if (isTermux) {
|
|
188
|
+
setupRipgrep(claudeCodePath);
|
|
189
|
+
copyLinuxBinariesAsAndroidFallback(claudeCodePath);
|
|
190
|
+
setupOAuthStorage();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
console.log('[claude-code-termux] Post-install complete!');
|
|
194
|
+
|
|
195
|
+
if (isTermux) {
|
|
196
|
+
console.log('\n[claude-code-termux] Termux setup tips:');
|
|
197
|
+
console.log(' - If you encounter Sharp errors, run: npm install @img/sharp-wasm32 --force');
|
|
198
|
+
console.log(' - If you encounter ripgrep errors, run: pkg install ripgrep');
|
|
199
|
+
console.log(' - Use API key auth: export ANTHROPIC_API_KEY=your-key');
|
|
200
|
+
console.log('\nRun "claude" to start Claude Code!');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
main();
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Download ripgrep for ARM64 Linux (works on Termux)
|
|
4
|
+
# This script downloads and extracts the ripgrep binary
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
9
|
+
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
10
|
+
BINARIES_DIR="$PROJECT_DIR/src/binaries"
|
|
11
|
+
|
|
12
|
+
# Ripgrep version and URL
|
|
13
|
+
RG_VERSION="14.1.1"
|
|
14
|
+
RG_URL="https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}/ripgrep-${RG_VERSION}-aarch64-unknown-linux-gnu.tar.gz"
|
|
15
|
+
|
|
16
|
+
echo "Downloading ripgrep v${RG_VERSION} for ARM64..."
|
|
17
|
+
|
|
18
|
+
# Create binaries directory
|
|
19
|
+
mkdir -p "$BINARIES_DIR"
|
|
20
|
+
|
|
21
|
+
# Create temp directory
|
|
22
|
+
TMP_DIR=$(mktemp -d)
|
|
23
|
+
trap "rm -rf $TMP_DIR" EXIT
|
|
24
|
+
|
|
25
|
+
# Download
|
|
26
|
+
curl -sL "$RG_URL" -o "$TMP_DIR/ripgrep.tar.gz"
|
|
27
|
+
|
|
28
|
+
# Extract
|
|
29
|
+
tar -xzf "$TMP_DIR/ripgrep.tar.gz" -C "$TMP_DIR"
|
|
30
|
+
|
|
31
|
+
# Find and copy the binary
|
|
32
|
+
RG_BINARY=$(find "$TMP_DIR" -name "rg" -type f | head -1)
|
|
33
|
+
|
|
34
|
+
if [[ -z "$RG_BINARY" ]]; then
|
|
35
|
+
echo "Error: ripgrep binary not found in archive"
|
|
36
|
+
exit 1
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
cp "$RG_BINARY" "$BINARIES_DIR/rg"
|
|
40
|
+
chmod +x "$BINARIES_DIR/rg"
|
|
41
|
+
|
|
42
|
+
echo "Ripgrep binary saved to: $BINARIES_DIR/rg"
|
|
43
|
+
echo ""
|
|
44
|
+
|
|
45
|
+
# Verify
|
|
46
|
+
if [[ -x "$BINARIES_DIR/rg" ]]; then
|
|
47
|
+
echo "Verification:"
|
|
48
|
+
file "$BINARIES_DIR/rg"
|
|
49
|
+
ls -la "$BINARIES_DIR/rg"
|
|
50
|
+
echo ""
|
|
51
|
+
echo "Success! Ripgrep binary is ready."
|
|
52
|
+
else
|
|
53
|
+
echo "Error: Binary verification failed"
|
|
54
|
+
exit 1
|
|
55
|
+
fi
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Claude Code Termux Setup Script
|
|
4
|
+
# This script sets up Claude Code with Termux compatibility fixes
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
echo "========================================"
|
|
9
|
+
echo " Claude Code Termux Setup"
|
|
10
|
+
echo "========================================"
|
|
11
|
+
echo ""
|
|
12
|
+
|
|
13
|
+
# Colors for output
|
|
14
|
+
RED='\033[0;31m'
|
|
15
|
+
GREEN='\033[0;32m'
|
|
16
|
+
YELLOW='\033[1;33m'
|
|
17
|
+
NC='\033[0m' # No Color
|
|
18
|
+
|
|
19
|
+
# Check if running in Termux
|
|
20
|
+
if [[ -z "$PREFIX" ]] || [[ ! "$PREFIX" == *"com.termux"* ]]; then
|
|
21
|
+
echo -e "${YELLOW}Warning: This script is designed for Termux on Android${NC}"
|
|
22
|
+
echo "Current PREFIX: $PREFIX"
|
|
23
|
+
read -p "Continue anyway? (y/N) " -n 1 -r
|
|
24
|
+
echo
|
|
25
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# Step 1: Update packages
|
|
31
|
+
echo -e "${GREEN}[1/6]${NC} Updating Termux packages..."
|
|
32
|
+
pkg update -y && pkg upgrade -y
|
|
33
|
+
|
|
34
|
+
# Step 2: Install Node.js
|
|
35
|
+
echo -e "${GREEN}[2/6]${NC} Installing Node.js..."
|
|
36
|
+
if command -v node &> /dev/null; then
|
|
37
|
+
NODE_VERSION=$(node --version)
|
|
38
|
+
echo "Node.js already installed: $NODE_VERSION"
|
|
39
|
+
else
|
|
40
|
+
pkg install nodejs -y
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Check Node.js version
|
|
44
|
+
NODE_MAJOR=$(node --version | cut -d'.' -f1 | tr -d 'v')
|
|
45
|
+
if [[ "$NODE_MAJOR" -lt 18 ]]; then
|
|
46
|
+
echo -e "${RED}Error: Node.js 18+ required, found v$NODE_MAJOR${NC}"
|
|
47
|
+
exit 1
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
if [[ "$NODE_MAJOR" -ge 25 ]]; then
|
|
51
|
+
echo -e "${YELLOW}Warning: Node.js 25+ may have compatibility issues${NC}"
|
|
52
|
+
echo "Consider installing Node.js 24: pkg install nodejs-lts"
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
# Step 3: Install git
|
|
56
|
+
echo -e "${GREEN}[3/6]${NC} Installing git..."
|
|
57
|
+
if command -v git &> /dev/null; then
|
|
58
|
+
echo "Git already installed"
|
|
59
|
+
else
|
|
60
|
+
pkg install git -y
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# Step 4: Install ripgrep
|
|
64
|
+
echo -e "${GREEN}[4/6]${NC} Installing ripgrep..."
|
|
65
|
+
if command -v rg &> /dev/null; then
|
|
66
|
+
echo "Ripgrep already installed"
|
|
67
|
+
else
|
|
68
|
+
pkg install ripgrep -y
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# Step 5: Install Claude Code Termux
|
|
72
|
+
echo -e "${GREEN}[5/6]${NC} Installing Claude Code Termux..."
|
|
73
|
+
|
|
74
|
+
# Check if already installed
|
|
75
|
+
if npm list -g claude-code-termux &> /dev/null; then
|
|
76
|
+
echo "Updating existing installation..."
|
|
77
|
+
npm update -g claude-code-termux
|
|
78
|
+
else
|
|
79
|
+
npm install -g claude-code-termux
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
# Also install Sharp WASM for image support
|
|
83
|
+
echo "Installing Sharp WASM for image support..."
|
|
84
|
+
npm install -g @img/sharp-wasm32 --force 2>/dev/null || true
|
|
85
|
+
|
|
86
|
+
# Step 6: Verify installation
|
|
87
|
+
echo -e "${GREEN}[6/6]${NC} Verifying installation..."
|
|
88
|
+
|
|
89
|
+
if command -v claude &> /dev/null; then
|
|
90
|
+
echo -e "${GREEN}Claude Code Termux installed successfully!${NC}"
|
|
91
|
+
else
|
|
92
|
+
echo -e "${YELLOW}Warning: 'claude' command not found in PATH${NC}"
|
|
93
|
+
echo "You may need to restart your terminal or add npm global bin to PATH:"
|
|
94
|
+
echo " export PATH=\$PATH:\$(npm config get prefix)/bin"
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
echo ""
|
|
98
|
+
echo "========================================"
|
|
99
|
+
echo " Setup Complete!"
|
|
100
|
+
echo "========================================"
|
|
101
|
+
echo ""
|
|
102
|
+
echo "Next steps:"
|
|
103
|
+
echo ""
|
|
104
|
+
echo "1. Set your API key:"
|
|
105
|
+
echo " export ANTHROPIC_API_KEY=your-api-key"
|
|
106
|
+
echo ""
|
|
107
|
+
echo "2. Add to .bashrc for persistence:"
|
|
108
|
+
echo " echo 'export ANTHROPIC_API_KEY=your-key' >> ~/.bashrc"
|
|
109
|
+
echo ""
|
|
110
|
+
echo "3. Start Claude Code:"
|
|
111
|
+
echo " claude"
|
|
112
|
+
echo ""
|
|
113
|
+
echo "For OAuth login (experimental):"
|
|
114
|
+
echo " claude login"
|
|
115
|
+
echo ""
|
|
116
|
+
echo "Troubleshooting:"
|
|
117
|
+
echo "- If you get Sharp errors: npm install @img/sharp-wasm32 --force"
|
|
118
|
+
echo "- If you get ripgrep errors: pkg install ripgrep"
|
|
119
|
+
echo "- Set DEBUG=1 for verbose output"
|
|
120
|
+
echo ""
|