Fixing AI CLI Path Issues

Fixing AI CLI Path Issues

Calliope Integration: This component is integrated into the Calliope AI platform. Some features and configurations may differ from the upstream project.

Problem

AI CLI tools (Claude, Gemini, Codex) are installed but not found in PATH:

❌ claude-WAIIDE not in PATH
❌ gemini-cli not in PATH

Root Cause

The npm global packages are installed in a non-standard location and the symlinks are not created properly.

Solution

Permanent Fix (Rebuild Docker Image)

The Dockerfile has been updated to:

  1. Dynamically detect the npm global bin directory
  2. Create proper symlinks for all AI CLI executables
  3. Set up PATH configuration in /etc/profile.d/npm-path.sh

Rebuild the image:

docker compose build
docker compose up -d

Quick Fix (Running Container)

Two scripts are available to fix the issue in a running container:

1. Fix AI CLI Paths Script

# Copy and run the fix script
docker cp scripts/fix-ai-cli-paths.sh calliope-web-ai-ide:/tmp/
docker exec -it calliope-web-ai-ide sudo bash /tmp/fix-ai-cli-paths.sh

This script will:

  • Find the npm global bin directory
  • Create symlinks in /usr/local/bin for all AI CLI tools
  • Update PATH configuration
  • Verify the installation

2. Configure AI CLIs Script

# This runs automatically on container start
docker exec -it calliope-web-ai-ide bash /opt/calliope/scripts/configure-ai-clis.sh

This script will:

  • Configure API keys for each CLI
  • Test authentication
  • Show installation paths

Manual Fix

If you need to fix it manually:

# Inside the container as root
NPM_GLOBAL_BIN=$(npm bin -g)
ln -sf $NPM_GLOBAL_BIN/claude /usr/local/bin/claude
ln -sf $NPM_GLOBAL_BIN/claude /usr/local/bin/claude-WAIIDE
ln -sf $NPM_GLOBAL_BIN/gemini /usr/local/bin/gemini
ln -sf $NPM_GLOBAL_BIN/gemini /usr/local/bin/gemini-cli
ln -sf $NPM_GLOBAL_BIN/codex /usr/local/bin/codex

# Update PATH
echo "export PATH=\"$NPM_GLOBAL_BIN:/usr/local/bin:\$PATH\"" >> /etc/profile.d/npm-path.sh
chmod +x /etc/profile.d/npm-path.sh
source /etc/profile.d/npm-path.sh

Verification

After applying the fix, verify the CLIs are available:

which claude-WAIIDE
which gemini-cli
which codex

# Or use the verification in the fix script
docker exec -it calliope-web-ai-ide bash -c "which claude && which gemini && which codex"

Environment Variables

Make sure these are set in your Docker Compose or environment:

  • ANTHROPIC_API_KEY - For Claude CLI
  • GOOGLE_API_KEY - For Gemini CLI
  • OPENAI_API_KEY - For Codex CLI

Updated Files

  • Dockerfile - Improved AI CLI installation with dynamic path detection
  • scripts/entrypoint-jupyterhub.sh - Updated PATH handling
  • scripts/configure-ai-clis.sh - Enhanced command detection
  • scripts/fix-ai-cli-paths.sh - New fix script for running containers