Skip to content

Troubleshooting Guide

Common issues and solutions for setting up and running the Micro-Learning Platform API.

Installation Issues

"xcode-select: note: install requested for command line developer tools"

Problem: macOS is requesting Xcode Command Line Tools installation when trying to use Homebrew.

Why it happens: Homebrew requires Xcode Command Line Tools to compile packages. This is a one-time setup requirement on macOS.

Solution 1: Install Xcode Command Line Tools (Recommended)

# Trigger the installation
xcode-select --install

This will: 1. Show a popup dialog asking to install the tools 2. Click "Install" and wait for the download (10-15 minutes) 3. Accept the license agreement when prompted

Verify installation:

xcode-select -p
# Should output: /Library/Developer/CommandLineTools

Solution 2: Use Alternative Installation Methods

If you don't want to install Xcode Command Line Tools, use these alternatives:

Install Deno:

# Official installer (no Xcode tools needed)
curl -fsSL https://deno.land/install.sh | sh

# Add to PATH (add to ~/.zshrc or ~/.bash_profile)
export PATH="$HOME/.deno/bin:$PATH"

Install Supabase CLI:

# Using npm (if you have Node.js)
npm install -g supabase

# OR using official installer
curl -fsSL https://supabase.com/install.sh | sh

Solution 3: Fix Corrupted Installation

If Xcode tools are installed but not working:

# Reset the installation
sudo xcode-select --reset

# Reinstall
xcode-select --install

# If still having issues, manually download from:
# https://developer.apple.com/download/all/

Supabase Issues

Supabase won't start

Problem: supabase start fails or hangs.

Solutions:

  1. Check Docker is running:

    docker ps
    # If error, start Docker Desktop
    

  2. Check port conflicts:

    # Check if ports are in use
    lsof -i :54321  # API port
    lsof -i :54322  # Database port
    lsof -i :54323  # Studio port
    
    # If ports are in use, stop the conflicting service or change ports in supabase/config.toml
    

  3. Reset Supabase:

    supabase stop
    supabase start
    

  4. Check Docker resources:

  5. Open Docker Desktop
  6. Go to Settings > Resources
  7. Ensure you have at least 4GB RAM allocated
  8. Ensure you have at least 2 CPU cores allocated

"Cannot connect to Docker daemon"

Problem: Docker daemon is not running.

Solution:

# Start Docker Desktop application
open -a Docker

# Wait for Docker to start (check the menu bar icon)
# Then verify it's running
docker ps

Database connection errors

Problem: API can't connect to Supabase database.

Solutions:

  1. Verify Supabase is running:

    supabase status
    

  2. Check .env file:

    # Ensure .env exists and has correct values
    cat .env
    
    # Get correct values
    supabase status
    

  3. Verify Supabase URL:

  4. Local development should use: http://127.0.0.1:54321
  5. Not http://localhost:54321 (can cause issues)

  6. Test database connection:

    # Connect directly to PostgreSQL
    psql postgresql://postgres:postgres@127.0.0.1:54322/postgres
    

API Server Issues

"Missing Supabase configuration" error

Problem: API server can't find environment variables.

Solutions:

  1. Create .env file:

    cp env.example .env
    # Edit .env with your Supabase credentials
    

  2. Verify .env file location:

  3. Must be in project root (same directory as deno.json)
  4. Check: ls -la .env

  5. Check environment variables:

    # The dev script should show loaded variables
    deno task dev
    # Look for: "✅ Loaded environment variables from .env file"
    

Port 8000 already in use

Problem: Another service is using port 8000.

Solutions:

  1. Find and stop the conflicting service:

    lsof -i :8000
    # Kill the process (replace PID with actual process ID)
    kill -9 <PID>
    

  2. Use a different port: Edit src/dev.ts and change:

    Deno.serve({ port: 8001 }, ...)  // Use different port
    

API returns 500 errors

Problem: API is running but endpoints return errors.

Solutions:

  1. Check Supabase connection:

    # Verify Supabase is running
    supabase status
    
    # Test API health endpoint
    curl http://localhost:8000/health
    

  2. Check API logs:

  3. Look at the terminal running deno task dev
  4. Check for error messages

  5. Verify database schema:

    # Ensure migrations are applied
    supabase db reset
    

Database Issues

Migration errors

Problem: Database migrations fail to apply.

Solutions:

  1. Check migration syntax:

    # View migration file
    cat supabase/migrations/20241229000001_create_microlearning_schema.sql
    

  2. Reset database:

    supabase db reset
    

  3. Check for conflicting migrations:

    supabase migration list
    

  4. Manually apply migration:

  5. Open Supabase Studio: http://127.0.0.1:54323
  6. Go to SQL Editor
  7. Copy migration SQL and run it manually

"Table already exists" errors

Problem: Trying to create tables that already exist.

Solution:

# Reset database (drops all tables and recreates)
supabase db reset

Warning: This will delete all data in your local database.

Deno Issues

"Permission denied" errors

Problem: Deno doesn't have required permissions.

Solution: The deno.json task should include all necessary permissions:

{
  "tasks": {
    "dev": "deno run --allow-net --allow-env --allow-read --watch src/dev.ts"
  }
}

If you're running Deno manually, add the flags:

deno run --allow-net --allow-env --allow-read src/dev.ts

Deno not found

Problem: deno command not found.

Solutions:

  1. If installed via installer:

    # Add to PATH (add to ~/.zshrc or ~/.bash_profile)
    export PATH="$HOME/.deno/bin:$PATH"
    
    # Reload shell
    source ~/.zshrc  # or source ~/.bash_profile
    

  2. If installed via Homebrew:

    # Verify installation
    brew list deno
    
    # Reinstall if needed
    brew reinstall deno
    

  3. Verify installation:

    which deno
    deno --version
    

Getting Help

If you're still experiencing issues:

  1. Check the logs:
  2. API server: Check terminal output
  3. Supabase services: docker logs supabase_db_core (or other container name)
  4. Docker: Check Docker Desktop logs or use docker logs <container-name>

  5. Verify all prerequisites:

  6. Deno installed: deno --version
  7. Supabase CLI installed: supabase --version
  8. Docker running: docker ps

  9. Review documentation:

  10. Database Setup Guide
  11. Developer Guide

  12. Common checks:

    # Check all services
    supabase status
    docker ps
    deno --version
    supabase --version
    
    # Verify environment
    cat .env
    ls -la .env