Troubleshooting

A guide to diagnosing and resolving common Anvil issues.

1. Installation Issues

Anvil won't run

Symptoms:

  • "anvil" is not recognized as a command
  • Application crashes immediately

Solutions:

  1. Check PATH configuration

    Windows:

    where.exe anvil
    # If not found, add to PATH
    $env:PATH += ";C:\path\to\anvil"
    

    Linux/macOS:

    which anvil
    # If not found, add to PATH
    export PATH="$PATH:/path/to/anvil"
    
  2. Verify platform compatibility

    • Anvil currently requires Windows 10 (1809+) or Windows 11
    • Cross-platform support is on the roadmap
  3. Verify the download isn't corrupted

    • Re-download from the releases page
    • Verify the file hash if provided

Package manager not found

Symptoms:

  • Error: "winget is not recognized"
  • Error: "Package manager not available"
  • Package installation fails before starting

Solutions (Windows — winget):

  1. Install Windows Package Manager

    # Open Microsoft Store to App Installer
    Start-Process "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1"
    
  2. Update App Installer

    • Open Microsoft Store → search "App Installer" → click "Update"
  3. Test availability

    winget --version
    
  4. Restart your terminal after installing winget


2. Package Installation Issues

Package not found

Symptoms:

  • Error: "No package found matching input criteria"
  • Error: "Package 'X' not found in any source"

Solutions:

  1. Verify package ID

    winget search <package-name>
    winget search --exact "Package Name"
    
  2. Check package source in workload

    packages:
      winget:
        - id: SomeApp.App
          source: msstore    # For Microsoft Store apps
    
  3. Update package sources

    winget source update
    

Installation hangs

Symptoms:

  • Installation appears frozen
  • No progress for extended time

Solutions:

  1. Check for interactive prompts

    • Some installers require user interaction
    • Run anvil without --quiet to see prompts
  2. Use silent install overrides

    packages:
      winget:
        - id: SomeApp.App
          override:
            - "--silent"
            - "--accept-license"
    
  3. Check for pending system updates

    • Pending OS updates can block installations
    • Complete any pending updates and restart

Access denied during installation

Symptoms:

  • Error: "Access is denied"
  • Error: "Administrator privileges required"

Solutions:

  1. Run with elevation (Windows)

    Start-Process powershell -Verb RunAs
    anvil install my-workload
    
  2. Use user-scope installation

    packages:
      winget:
        - id: Package.Name
          override:
            - "--scope"
            - "user"
    

3. File Operation Issues

Permission denied

Symptoms:

  • Error: "Permission denied" when copying files
  • File operations fail

Solutions:

  1. Use user-writable paths

    files:
      - source: config.json
        destination: "~/.config/app/config.json"  # Expands to user home
    
  2. Check target directory permissions

    Windows:

    Get-Acl "C:\path\to\directory" | Format-List
    

    Linux/macOS:

    ls -la /path/to/directory
    
  3. Run as administrator for system-level paths


File not found

Symptoms:

  • Error: "Source file not found"

Solutions:

  1. Verify source path — paths are relative to the workload directory

    files:
      - source: files/config.json      # Relative to workload dir
        destination: "~/.config/app/config.json"
    
  2. Check workload directory structure

    my-workload/
    ├── workload.yaml
    └── files/
        └── config.json
    

Backup failed

Symptoms:

  • Error: "Failed to create backup"

Solutions:

  1. Check disk space
  2. Verify backup directory exists and is writable
    $env:ANVIL_BACKUP_DIR = "D:\Backups\anvil"
    

4. Script Execution Issues

Script won't execute

Symptoms:

  • Error: "Script execution failed"
  • No output from script

Solutions:

  1. Verify script path in workload.yaml — paths are relative to scripts/

    scripts:
      post_install:
        - path: setup.ps1    # Relative to scripts/ directory
    
  2. Test script manually

    & "C:\workloads\my-workload\scripts\setup.ps1"
    

Execution policy error (Windows)

Symptoms:

  • Error: "Running scripts is disabled on this system"

Solutions:

  1. Set execution policy

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
    
  2. Check group policy — corporate environments may have stricter policies


Script timeout

Symptoms:

  • Error: "Script execution timed out"

Solutions:

  1. Increase timeout in workload

    scripts:
      post_install:
        - path: scripts/long-running.ps1
          timeout: 1800    # 30 minutes (default: 300)
    
  2. Check for infinite loops or slow network operations in the script


Elevated script fails (Windows)

Symptoms:

  • Error: "Elevation required"

Solutions:

  1. Run anvil as administrator
  2. Set the elevated flag in workload.yaml
    scripts:
      post_install:
        - path: scripts/admin-setup.ps1
          elevated: true
    

5. Health Check Issues

False failures

Symptoms:

  • Health check fails but software is working
  • Intermittent failures

Solutions:

  1. Run with verbose output

    anvil health my-workload --verbose
    
  2. Review health check scripts — they may have outdated expectations

  3. Update version expectations

    winget list --id Package.Name
    

Partial results

Symptoms:

  • Some checks don't run
  • Health report incomplete

Solutions:

  1. Check verbose output for errors in earlier checks

    anvil health my-workload -vvv
    
  2. Verify all referenced scripts exist in the workload directory


6. Configuration Issues

Config file not loading

Symptoms:

  • Settings not applied
  • Default values used instead of custom

Solutions:

  1. Check config location

    anvil config path
    
  2. View current configuration

    anvil config list
    
  3. Reset to defaults

    anvil config reset
    

Workloads not found

Symptoms:

  • Error: "Workload 'X' not found"
  • Empty list from anvil list

Solutions:

  1. Check search paths

    anvil config list
    
  2. Verify workload structure — needs a workload.yaml file

    workload-name/
    └── workload.yaml
    
  3. Use explicit path

    anvil install my-workload --path /path/to/workloads
    

7. Error Reference

Common Error Codes

ErrorDescriptionSolution
E001Workload not foundCheck name and search paths
E002Invalid workload schemaRun anvil validate for details
E003Circular dependencyReview extends chain in workloads
E004Package installation failedCheck package manager logs, verify package ID
E005File operation failedCheck permissions, verify paths
E006Script execution failedReview script output, check syntax
E007Health check failedReview check results, update scripts
E008Configuration errorValidate config file syntax
E009Backup operation failedCheck disk space and permissions
E010Restore operation failedVerify backup exists and is valid

8. Getting Help

Verbose Output

Get more detailed information about what Anvil is doing:

anvil -v <command>      # Some detail
anvil -vv <command>     # More detail
anvil -vvv <command>    # Maximum detail (debug level)

Enable Logging

# Set log level via environment variable
ANVIL_LOG=debug anvil install my-workload

# Available levels: error, warn, info, debug, trace

System Information

Gather helpful information when reporting issues:

# Anvil version
anvil --version

# Operating system
# Windows: winver
# Linux/macOS: uname -a

# Package manager version
winget --version        # Windows

Reporting Issues

When reporting issues, include:

  1. Anvil version: anvil --version
  2. Operating system and version
  3. Command that failed: exact command you ran
  4. Error message: complete error output
  5. Verbose output: run with -vvv flag
  6. Workload file: contents of workload.yaml (sanitized if needed)

Resources


Quick Reference

Common Commands for Troubleshooting

# Check Anvil installation
anvil --version

# Validate workload
anvil validate my-workload --strict

# Preview installation (dry run)
anvil install my-workload --dry-run

# Verbose health check
anvil health my-workload -vvv

# View current configuration
anvil config list

# Reset configuration
anvil config reset

Environment Variables

VariablePurpose
ANVIL_CONFIGCustom config file path
ANVIL_WORKLOADSAdditional workload search paths
ANVIL_LOGLog level (error, warn, info, debug, trace)
ANVIL_BACKUP_DIRCustom backup directory
NO_COLORDisable colored output