npm_modules/cli/LINUX_COMPATIBILITY.md
This document describes how the Valdi CLI handles different Linux distributions.
The Valdi CLI (valdi doctor and valdi dev_setup commands) now supports multiple Linux distributions beyond just Debian/Ubuntu. The CLI automatically detects your distribution and uses the appropriate package manager and package names.
aptRed Hat-based: Fedora, RHEL, CentOS, Rocky Linux, AlmaLinux
dnf or yumArch-based: Arch Linux, Manjaro, EndeavourOS
pacmanSUSE-based: openSUSE, SLES
zypperThe CLI detects your distribution using the following methods (in order):
/etc/os-release: Reads the standard Linux distribution information file
ID and ID_LIKE fields to determine distribution familyPackage Manager Detection: Falls back to detecting available package managers
apt-get, dnf, yum, pacman, or zypperUnknown Distributions: If detection fails, provides manual installation instructions
Different distributions use different package names for the same software. The CLI includes mappings for common dependencies:
| Dependency | Debian/Ubuntu | Red Hat/Fedora | Arch Linux | openSUSE |
|---|---|---|---|---|
| Java 17 JDK | openjdk-17-jdk | java-17-openjdk-devel | jdk17-openjdk | java-17-openjdk-devel |
| Android Debug Bridge | adb | android-tools | android-tools | android-tools |
| Fontconfig Dev | libfontconfig1-dev | fontconfig-devel | fontconfig | fontconfig-devel |
| Zlib Dev | zlib1g-dev | zlib-devel | zlib | zlib-devel |
| Git LFS | git-lfs | git-lfs | git-lfs | git-lfs |
| Watchman | watchman | watchman | watchman | watchman |
valdi dev_setupThe dev_setup command automatically installs required dependencies for your distribution:
valdi dev_setup
What it does:
Distribution-specific behavior:
Debian/Ubuntu:
libtinfo5 for Android command-line tools compatibilityRed Hat/Fedora:
ncurses-compat-libs for Android toolsArch Linux:
openSUSE:
valdi doctorThe doctor command checks your development environment and provides distribution-specific fix commands:
valdi doctor
Features:
Example output on Fedora:
Running Valdi environment diagnostics...
Detected distribution: Fedora Linux (dnf)
✓ Node.js installation
✗ Java installation
• Java not found in PATH
Fix: sudo dnf install java-17-openjdk-devel
Watchman may not be available in the default repositories. Enable EPEL:
# Fedora
sudo dnf install epel-release
# RHEL/CentOS
sudo yum install epel-release
Then install watchman:
sudo dnf install watchman
# or
sudo yum install watchman
Some packages may only be available in the AUR. Use an AUR helper like yay or paru:
yay -S watchman
If your distribution is not automatically detected, you'll see:
Unable to detect Linux distribution.
Please manually install the following dependencies and re-run this command:
- git
- git-lfs
- npm (Node.js)
- openjdk-17-jdk (or equivalent Java 17 JDK)
- watchman
- adb (Android Debug Bridge)
- fontconfig development libraries
- zlib development libraries
Consult your distribution's package manager documentation for the correct package names.
If distribution detection fails or provides incorrect results:
Check that /etc/os-release exists and is readable:
cat /etc/os-release
Verify your package manager is in PATH:
which apt-get # or dnf, yum, pacman, zypper
Report the issue with your distribution details:
cat /etc/os-releaseTo add support for a new distribution:
Add package mappings in src/utils/linuxDistro.ts:
// In getCommonPackageMappings()
'your-package': {
debian: 'debian-package-name',
redhat: 'redhat-package-name',
arch: 'arch-package-name',
suse: 'suse-package-name',
fallback: 'generic-package-name',
}
Add distribution detection logic in detectLinuxDistro() if needed
Test on the target distribution:
valdi dev_setup
valdi doctor
Update this documentation with your findings
src/utils/linuxDistro.ts - Distribution detection and package mapping utilitiessrc/setup/linuxSetup.ts - Linux-specific dev_setup implementationsrc/commands/doctor.ts - Environment diagnostics with distribution-aware fix commandsimport { detectLinuxDistro, buildInstallCommand, getPackageName } from './utils/linuxDistro';
// Detect distribution
const distro = detectLinuxDistro();
console.log(distro.name); // e.g., "Ubuntu"
console.log(distro.type); // e.g., LinuxDistroType.DEBIAN
console.log(distro.packageManager.name); // e.g., "apt"
// Build install command
const cmd = buildInstallCommand(['git', 'npm', 'watchman'], distro);
console.log(cmd); // e.g., "sudo apt-get install git npm watchman"
// Get package name for current distribution
const packageMappings = getCommonPackageMappings();
const javaPackage = getPackageName(packageMappings['openjdk-17'], distro);
console.log(javaPackage); // e.g., "openjdk-17-jdk" on Ubuntu