githubEdit

Debugging Guide

This guide covers debugging techniques for spuff development.

Logging

Enable Debug Logging

# General debug logging
RUST_LOG=debug cargo run -- up

# Spuff-specific logging
RUST_LOG=spuff=debug cargo run -- status

# Trace level (very verbose)
RUST_LOG=spuff=trace cargo run -- up

# Multiple modules
RUST_LOG=spuff=debug,reqwest=debug cargo run -- up

Log Levels

Level
Use Case

error

Errors that stop execution

warn

Potential issues

info

Normal operation events

debug

Detailed flow information

trace

Very detailed, including data

Adding Logs to Code

Debugging VM Bootstrap

Cloud-Init Logs

SSH into the VM and check:

Bootstrap Status

Agent Logs

Debugging SSH Issues

Verbose SSH

Common SSH Issues

Permission denied:

Key requires passphrase:

Host key verification:

Debugging Provider API

Log API Requests

Inspect with curl

Debugging Local State

SQLite Inspection

Reset State

Debugging Agent

Local Agent Testing

Agent on VM

Debugging TUI

Disable TUI

For debugging, you can disable the TUI:

TUI Fallback

When TUI fails, spuff falls back to text output. Check stderr for TUI errors.

IDE Debugging

VS Code (CodeLLDB)

  1. Install CodeLLDB extension

  2. Create launch configuration:

  1. Set breakpoints and press F5

RustRover/IntelliJ

  1. Create Run Configuration

  2. Set binary: spuff

  3. Set arguments: status

  4. Set environment variables

  5. Click Debug

Common Issues

"Device not configured" (TUI Error)

The terminal is not properly initialized:

"Permission denied" on SSH

  1. Check key is added to agent: ssh-add -l

  2. Check key is uploaded to provider

  3. Check key permissions: chmod 600 ~/.ssh/id_*

Instance Not Found

State may be out of sync:

Cloud-Init Never Completes

Check for errors:

Profiling

CPU Profiling

Memory Profiling

Useful Commands Cheatsheet

Last updated

Was this helpful?