-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
Problem
On Android (Termux), the postinstall script fails when trying to download prebuilt ripgrep binaries due to:
- Platform compatibility issues with prebuilt binaries
- The
getTarget()function throws "Unknown platform: android" - Network restrictions and architecture support limitations in Android environments
Current Behavior
When running npm install on Android, the postinstall script fails with:
Error: Unknown platform: android
at getTarget (/path/to/lib/postinstall.js:49:24)
Proposed Solution
Add Android platform detection to use system-installed ripgrep via symlink before falling back to downloads. This leverages the well-maintained ripgrep package available in Termux.
Code Implementation
Add this logic to the main() function in lib/postinstall.js:
// Handle Android specially - try to use system ripgrep if available
if (os.platform() === 'android') {
console.log('Android detected, checking for system ripgrep...');
try {
const result = await exec('which rg');
const systemRgPath = result.stdout.trim();
if (systemRgPath) {
console.log(`Found system ripgrep at ${systemRgPath}`);
const targetRgPath = path.join(BIN_PATH, 'rg');
// Remove existing symlink/file if it exists
try {
await util.promisify(fs.unlink)(targetRgPath);
} catch (err) {
// Ignore error if file doesn't exist
}
// Create symlink to system ripgrep
await util.promisify(fs.symlink)(systemRgPath, targetRgPath);
console.log(`Created symlink from ${targetRgPath} to ${systemRgPath}`);
return;
}
} catch (err) {
console.log('System ripgrep not found, falling back to download...');
}
}Benefits of This Approach
- Reliability: Uses Termux's well-tested ripgrep package that works across Android devices
- Performance: Native builds optimized for the specific Android environment
- Compatibility: Avoids architecture and library compatibility issues with prebuilt binaries
- Maintenance: Leverages Termux package management for updates and security patches
- Graceful fallback: Still attempts download if system ripgrep unavailable
Testing
Tested on Android (Termux) with system ripgrep available:
- ✅ Detects Android platform correctly
- ✅ Finds system ripgrep at
/data/data/com.termux/files/usr/bin/rg - ✅ Creates symlink successfully
- ✅ Symlinked ripgrep works correctly (
rg --versionshows expected output) - ✅ Handles existing symlinks by removing them first
Installation Instructions for Users
On Android/Termux, users should install ripgrep first:
pkg install ripgrepThen install vscode-ripgrep normally:
npm install vscode-ripgrepThe postinstall script will automatically detect and use the system ripgrep.
Metadata
Metadata
Assignees
Labels
No labels