Files
LEDMatrix/docs/PLUGIN_DEPENDENCY_TROUBLESHOOTING.md
Chuck b374bfa8c6 docs: fix plugin config + store + dependency docs
PLUGIN_STORE_GUIDE.md
- 19 occurrences of port 5050 -> 5000
- All API paths missing /v3 (e.g. /api/plugins/install ->
  /api/v3/plugins/install). Bulk fix.

PLUGIN_REGISTRY_SETUP_GUIDE.md
- Same port + /api/v3 fixes (3 occurrences each)
- "Go to Plugin Store tab" -> "Open the Plugin Manager tab and scroll
  to the Install from GitHub section" (the real flow for registry
  setup is the GitHub install section, not the Plugin Store search)

PLUGIN_CONFIG_QUICK_START.md
- Port 5001 -> 5000 (5001 is the dev_server.py default, not the web UI)
- "Plugin Store tab" install flow -> real Plugin Manager + Plugin Store
  section + per-plugin tab in second nav row
- Removed reference to PLUGIN_CONFIG_TABS_SUMMARY.md (archived doc)

PLUGIN_CONFIGURATION_TABS.md
- "Plugin Management vs Configuration" section confusingly described
  a "Plugins Tab" that doesn't exist as a single thing. Rewrote to
  describe the real two-piece structure: Plugin Manager tab (browse,
  install, toggle) vs per-plugin tabs (configure individual plugins).

PLUGIN_DEPENDENCY_GUIDE.md
- Port 5001 -> 5000

PLUGIN_DEPENDENCY_TROUBLESHOOTING.md
- Wrong port (8080) and wrong UI nav ("Plugin Store or Plugin
  Management"). Fixed to the real flow.

PLUGIN_QUICK_REFERENCE.md
- "Plugin Location: ./plugins/ directory" -> default is plugin-repos/
  (verified in config/config.template.json:130 and
  display_controller.py:132). plugins/ is a fallback.
- File structure diagram showed plugins/ -> plugin-repos/.
- Web UI install flow: "Plugin Store tab" -> "Plugin Manager tab ->
  Plugin Store section". Also fixed Configure ⚙️ button (doesn't
  exist) and "Drag and drop reorder" (not implemented).
- API examples: replaced ad-hoc Python pseudocode with real curl
  examples against /api/v3/plugins/* endpoints. Pointed at
  REST_API_REFERENCE.md for the full list.
- "Migration Path Phase 1-5" was a roadmap written before the plugin
  system shipped. The plugin system is now stable and live. Removed
  the migration phases as they're history, not a roadmap.
- "Quick Migration" section called scripts/migrate_to_plugins.py
  which doesn't exist anywhere in the repo. Removed.
- "Plugin Registry Structure" referenced
  ChuckBuilds/ledmatrix-plugin-registry which doesn't exist. The
  real registry is ChuckBuilds/ledmatrix-plugins. Fixed.
- "Next Steps" / "Questions to Resolve" sections were
  pre-implementation planning notes. Replaced with a "Known
  Limitations" section that documents the actually-real gaps
  (sandboxing, resource limits, ratings, auto-updates).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 22:10:05 -04:00

5.2 KiB

Plugin Dependency Installation Troubleshooting

This guide helps resolve issues with automatic plugin dependency installation in the LEDMatrix system.

Common Error Symptoms

Permission Errors

ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/root/.local'
WARNING: The directory '/root/.cache/pip' or its parent directory is not owned or is not writable

Context Mismatch

WARNING: Installing plugin dependencies for current user (not root). 
These will NOT be accessible to the systemd service.

Root Cause

Plugin dependencies must be installed in a context accessible to the LEDMatrix systemd service, which runs as root. Permission errors typically occur when:

  1. The pip cache directory has incorrect permissions
  2. The process tries to install to user directories without proper permissions
  3. Environment variables (like HOME) are not set correctly for the service context

Solutions

We provide a helper script that handles dependency installation correctly:

# Run as root to install system-wide (for production)
sudo /home/ledpi/LEDMatrix/scripts/install_plugin_dependencies.sh

# After installation, restart the service
sudo systemctl restart ledmatrix

This script:

  • Detects all plugins with requirements.txt files
  • Installs dependencies with correct permissions
  • Uses --no-cache-dir to avoid cache permission issues
  • Provides detailed logging for troubleshooting

Solution 2: Manual Installation per Plugin

If you need to install dependencies for a specific plugin:

# Navigate to the plugin directory
cd /home/ledpi/LEDMatrix/plugins/PLUGIN-NAME

# Install as root (system-wide)
sudo pip3 install --break-system-packages --no-cache-dir -r requirements.txt

# Restart the service
sudo systemctl restart ledmatrix

Solution 3: Fix Cache Directory Permissions

If you specifically have cache permission issues:

# Option A: Skip the cache (recommended)
sudo pip3 install --no-cache-dir --break-system-packages -r requirements.txt

# Option B: Fix cache permissions (if needed)
sudo mkdir -p /root/.cache/pip
sudo chown -R root:root /root/.cache
sudo chmod -R 755 /root/.cache

Solution 4: Install via Web Interface

The web interface handles dependency installation correctly in the service context:

  1. Access the web interface (http://ledpi:5000 or http://your-pi-ip:5000)
  2. Open the Plugin Manager tab (use the Plugin Store section to find the plugin, or Install from GitHub)
  3. Install the plugin through the web UI
  4. The system automatically handles dependency installation in the service context (which has the right permissions)

Prevention

For Plugin Developers

When creating plugins with dependencies:

  1. Keep requirements minimal: Only include essential packages
  2. Test installation: Verify your requirements.txt works with:
    sudo pip3 install --break-system-packages --no-cache-dir -r requirements.txt
    
  3. Document dependencies: Note any system packages needed (via apt)

For Users

  1. Use web interface: Install plugins via the web UI when possible
  2. Install as root: When using SSH/terminal, use sudo for plugin installations
  3. Restart service: After manual installations, restart the ledmatrix service

Technical Details

How Dependency Installation Works

The PluginManager._install_plugin_dependencies() method:

  1. Detects if running as root using os.geteuid() == 0
  2. If root: Uses system-wide installation with --break-system-packages --no-cache-dir
  3. If not root: Uses user installation with --user --break-system-packages --no-cache-dir
  4. The --no-cache-dir flag prevents cache-related permission issues

Why --break-system-packages?

Debian 12+ (Bookworm) and Raspberry Pi OS based on it implement PEP 668, which prevents pip from installing packages system-wide by default. The --break-system-packages flag overrides this protection, which is necessary for the plugin system.

Service Context

The ledmatrix.service runs as:

  • User: root
  • WorkingDirectory: /home/ledpi/LEDMatrix
  • Python: /usr/bin/python3

Dependencies must be installed in root's Python environment or system-wide to be accessible.

Checking Installation

Verify dependencies are installed correctly:

# Check as root (how the service sees it)
sudo python3 -c "import package_name"

# List installed packages
pip3 list

# Check specific package
pip3 show package_name

Getting Help

If you continue to experience issues:

  1. Check the service logs:

    sudo journalctl -u ledmatrix -f
    
  2. Check pip logs (created by manual script):

    cat /tmp/pip_install_*.log
    
  3. Verify plugin manifest is correct:

    cat /home/ledpi/LEDMatrix/plugins/PLUGIN-NAME/manifest.json
    
  4. Check plugin requirements:

    cat /home/ledpi/LEDMatrix/plugins/PLUGIN-NAME/requirements.txt