The darn library system has been enhanced with robust path resolution, validation, and error reporting to provide a more reliable and debuggable experience.
The library path is resolved using a clear hierarchy (highest to lowest priority):
- Command line flag (
--library-path) - DARN_HOME environment variable (for testing)
- Global config file setting (
~/.darn/config.yaml) - Default global library (
~/.darn/library)
- Library structure validation: Checks for required subdirectories (
actions/,templates/,configs/,mappings/) - Path accessibility: Verifies directories exist and are readable
- CLI command validation: Validates that CLI commands exist in PATH (for
cliaction type) - Cross-platform support: Handles Windows executable extensions
- Detailed error messages: Clear indication of what went wrong and where
- Verbose logging: Optional detailed output for debugging
- Diagnostic command: Built-in troubleshooting tool
When experiencing library or shell command issues, use the diagnostic command:
# Basic diagnostics
darn library diagnose
# Verbose output for debugging
darn library diagnose -v
# JSON output for automation
darn library diagnose --jsonFor testing or project-specific libraries, use the DARN_HOME environment variable:
# Use a temporary library for testing
DARN_HOME=/tmp/test-library darn library diagnose
# Set up a project-specific library
export DARN_HOME=/path/to/project-library
darn action list# Initialize a new library at default location
darn library init
# Initialize at custom location
darn library init /path/to/custom/library
# Set global library path
darn library set-global /path/to/custom/library
# Sync library with latest embedded defaults
darn library sync
# Sync with verbose output
darn library sync --verbose
# Preview what would be synced (dry run)
darn library sync --dry-runThe new library.Manager provides:
- Path resolution with environment-specific handling
- Validation of library structure and shell commands
- Diagnostics for troubleshooting
- Cross-platform compatibility
The enhanced Config struct includes:
LibraryManagerfor robust path handlingValidateLibrarySetup()for upfront validationGetLibraryDiagnostics()for debugging informationValidateShellCommand()for command validation
Instead of silent failures, the system now:
- Validates library paths at startup
- Reports specific error conditions
- Provides actionable recommendations
- Logs resolution attempts in verbose mode
-
Library not found
Solution: Run `darn library init` or `darn library set-global <path>` -
CLI commands not found
Solution: Install missing commands or check PATH environment variable -
Permission errors
Solution: Check directory permissions and user access rights
The diagnostic command identifies:
- Path resolution issues
- Missing directories
- Permission problems
- Shell command availability
- Environment variable settings
Use DARN_HOME for temporary testing:
# Create test library
mkdir -p /tmp/test-lib/{actions,templates,configs,mappings}
# Test with temporary library
DARN_HOME=/tmp/test-lib darn library diagnose
# Run operations with test library
DARN_HOME=/tmp/test-lib darn action listThe new CLI-based approach provides several commands for managing libraries:
darn library init- Initialize new libraries with standard structuredarn library sync- Update library with latest embedded defaultsdarn library diagnose- Troubleshoot library configuration issuesdarn library set-global- Configure global library pathdarn library update- Update library from source directory
- ✅ Cross-platform - Works on Windows, macOS, Linux
- ✅ Integrated validation - Checks paths and permissions
- ✅ Consistent interface - Same CLI patterns as other commands
- ✅ Better error handling - Clear, actionable error messages
- ✅ Dry-run support - Preview changes before applying
The improved system is backward compatible, but provides:
- Better error messages when things go wrong
- Validation that catches issues early
- Diagnostics for troubleshooting problems
- Consistent behavior across environments
- CLI-based management instead of shell scripts
Existing configurations will continue to work, but you'll get better feedback when there are issues.