|
| 1 | +# Ruby Debugging Setup for VS Code |
| 2 | + |
| 3 | +This repository includes a comprehensive Ruby debugging setup for Visual Studio Code, similar to the one in the agents-workflow repository. |
| 4 | + |
| 5 | +## Files Created |
| 6 | + |
| 7 | +### VS Code Configuration (`.vscode/`) |
| 8 | + |
| 9 | +- **`tasks.json`** - VS Code tasks for running and debugging Ruby code |
| 10 | +- **`launch.json`** - Debug configurations for rdbg debugger |
| 11 | +- **`settings.json`** - Ruby LSP settings and debugging preferences |
| 12 | + |
| 13 | +### Scripts |
| 14 | + |
| 15 | +- **`scripts/rdbg-wrapper`** - Wrapper script to locate and run rdbg without hardcoded paths |
| 16 | + |
| 17 | +## Available Tasks |
| 18 | + |
| 19 | +Use `Cmd+Shift+P` (macOS) or `Ctrl+Shift+P` (Windows/Linux) and search for "Tasks: Run Task": |
| 20 | + |
| 21 | +1. **Run Current Test File** - Execute the currently open test file |
| 22 | +2. **Run All Tests** - Execute all tests using the main test runner |
| 23 | +3. **Debug Current Test with Pry** - Run current test with Pry for interactive debugging |
| 24 | +4. **Simple Test Run (No Debug)** - Basic test execution without debug features |
| 25 | + |
| 26 | +## Debug Configurations |
| 27 | + |
| 28 | +Use the Debug panel (F5 or Run → Start Debugging): |
| 29 | + |
| 30 | +1. **Debug Current Ruby File** - Debug any Ruby file with rdbg |
| 31 | +2. **Debug Current Test File** - Debug test files with proper load paths |
| 32 | +3. **Debug All Tests** - Debug the complete test suite |
| 33 | + |
| 34 | +## Required Gems |
| 35 | + |
| 36 | +To use the debugging features, install these gems: |
| 37 | + |
| 38 | +```bash |
| 39 | +gem install debug pry |
| 40 | +``` |
| 41 | + |
| 42 | +### For Nix Users |
| 43 | + |
| 44 | +If you're using the nix development environment and encounter compilation issues: |
| 45 | + |
| 46 | +1. Use system Ruby for gem installation: |
| 47 | + |
| 48 | + ```bash |
| 49 | + # Exit nix shell first |
| 50 | + gem install debug pry |
| 51 | + ``` |
| 52 | + |
| 53 | +2. Or install globally and ensure they're available in PATH |
| 54 | + |
| 55 | +## Usage |
| 56 | + |
| 57 | +1. **Setting Breakpoints**: Click in the gutter next to line numbers or use `F9` |
| 58 | +2. **Interactive Debugging**: Use the "Debug Current Test with Pry" task for REPL-style debugging |
| 59 | +3. **Variable Inspection**: Hover over variables or use the Variables panel during debugging |
| 60 | +4. **Step Through Code**: Use F10 (step over), F11 (step into), Shift+F11 (step out) |
| 61 | + |
| 62 | +## Ruby LSP Features |
| 63 | + |
| 64 | +The setup includes full Ruby Language Server Protocol support: |
| 65 | + |
| 66 | +- Code completion and IntelliSense |
| 67 | +- Go to definition/implementation |
| 68 | +- Syntax highlighting and error detection |
| 69 | +- Code formatting and refactoring |
| 70 | +- Document symbols and workspace search |
| 71 | + |
| 72 | +## Troubleshooting |
| 73 | + |
| 74 | +- **"debug gem not found"**: Install the debug gem with `gem install debug` |
| 75 | +- **Compilation errors in nix**: Try using system Ruby for gem installation |
| 76 | +- **rdbg not found**: The rdbg-wrapper script should handle this automatically |
| 77 | +- **Breakpoints not working**: Ensure the debug gem is installed and accessible |
| 78 | + |
| 79 | +## Integration with Editor |
| 80 | + |
| 81 | +The configuration integrates seamlessly with VS Code's built-in features: |
| 82 | + |
| 83 | +- Debug console for evaluating expressions |
| 84 | +- Call stack navigation |
| 85 | +- Automatic variable inspection |
| 86 | +- Terminal integration for task execution |
0 commit comments