Environment Variables
Environment variables that influence kiln’s runtime behavior, key discovery, and integration capabilities.
Configuration Variables
Section titled “Configuration Variables”KILN_PRIVATE_KEY_FILE
Section titled “KILN_PRIVATE_KEY_FILE”Override automatic key discovery with explicit key file path.
Usage:
export KILN_PRIVATE_KEY_FILE=/path/to/specific.keykiln get DATABASE_URL --file productionBehavior:
- Takes precedence over automatic key discovery
- Must point to readable private key file
- Supports both age and SSH private keys
- Path can be absolute or relative to current directory
Common scenarios:
# CI/CD with specific deployment keyexport KILN_PRIVATE_KEY_FILE=/secrets/deploy.key
# Multiple team members on shared systemexport KILN_PRIVATE_KEY_FILE=~/.kiln/team-lead.key
# Testing with different access levelsexport KILN_PRIVATE_KEY_FILE=./keys/readonly.keyKILN_CONFIG_FILE
Section titled “KILN_CONFIG_FILE”Override default configuration file location.
Default: kiln.toml in current directory
Usage:
export KILN_CONFIG_FILE=/etc/kiln/global.tomlkiln info --verifyUse cases:
- System-wide configuration in
/etc/kiln/ - Project-specific config in subdirectories
- Multi-environment setups with different configs
Editor Integration
Section titled “Editor Integration”EDITOR
Section titled “EDITOR”Specifies the editor for the edit command.
Common configurations:
# Terminal editors (synchronous by default)export EDITOR=vimexport EDITOR=nanoexport EDITOR=emacs
# GUI editors (require wait flag)export EDITOR="code --wait"export EDITOR="subl --wait"export EDITOR="atom --wait"Editor requirements:
- Must exit only after file editing is complete
- Should support text file editing
- Must be available in system PATH
System Integration
Section titled “System Integration”Used by the run command for executable discovery.
Behavior:
- Standard PATH resolution for command execution
- Relative paths resolved from working directory
- Commands must be executable and accessible
TMPDIR
Section titled “TMPDIR”Controls temporary file location for the edit command.
Default: System default (/tmp on Unix, %TEMP% on Windows)
Security considerations:
# Use memory-backed filesystem for enhanced securityexport TMPDIR=/dev/shm
# Use project-specific temp directoryexport TMPDIR=./.tmpCI/CD Variables
Section titled “CI/CD Variables”Common Integration Patterns
Section titled “Common Integration Patterns”GitHub Actions:
env: KILN_PRIVATE_KEY_FILE: ${{ secrets.KILN_PRIVATE_KEY }} KILN_CONFIG_FILE: .github/kiln.tomlGitLab CI:
variables: KILN_PRIVATE_KEY_FILE: /tmp/deploy.keybefore_script: - echo "$KILN_PRIVATE_KEY" > /tmp/deploy.key - chmod 600 /tmp/deploy.keyDocker builds:
ENV KILN_PRIVATE_KEY_FILE=/secrets/kiln.keyENV KILN_CONFIG_FILE=/app/kiln.tomlRuntime Behavior Variables
Section titled “Runtime Behavior Variables”Key Discovery Order
Section titled “Key Discovery Order”When KILN_PRIVATE_KEY_FILE is not set, kiln searches in order:
~/.kiln/kiln.key(age key)~/.ssh/id_ed25519(SSH Ed25519)~/.ssh/id_rsa(SSH RSA)
Override with explicit setting:
export KILN_PRIVATE_KEY_FILE=~/.ssh/company_keyConfiguration Resolution
Section titled “Configuration Resolution”KILN_CONFIG_FILEif set--configcommand line flagkiln.tomlin current directory
Precedence example:
# Environment variable (lowest precedence)export KILN_CONFIG_FILE=global.toml
# Command flag overrides environmentkiln get VAR --config project.tomlSecurity Considerations
Section titled “Security Considerations”Sensitive Data
Section titled “Sensitive Data”Secure pattern:
# ✓ Good - file path onlyexport KILN_PRIVATE_KEY_FILE=/secure/path/key.pem
# ✗ Bad - sensitive data in environmentexport KILN_PRIVATE_KEY="AGE-SECRET-KEY-..."File Permissions
Section titled “File Permissions”Ensure referenced files have appropriate permissions:
# Private key fileschmod 600 $KILN_PRIVATE_KEY_FILE
# Configuration fileschmod 644 $KILN_CONFIG_FILEDebugging and Troubleshooting
Section titled “Debugging and Troubleshooting”Verbose Output
Section titled “Verbose Output”Use --verbose flag to see environment variable resolution:
kiln --verbose get DATABASE_URL# Shows: Loading config from /path/to/kiln.toml# Shows: Using private key /path/to/key.pemVariable Verification
Section titled “Variable Verification”Check current environment settings:
# Show all kiln-related variablesenv | grep KILN
# Verify file accessibilityls -la "$KILN_PRIVATE_KEY_FILE"ls -la "$KILN_CONFIG_FILE"Common Issues
Section titled “Common Issues”Key file not found:
# Check if variable is setecho "$KILN_PRIVATE_KEY_FILE"
# Verify file exists and is readabletest -r "$KILN_PRIVATE_KEY_FILE" && echo "OK" || echo "Not accessible"Editor not waiting:
# Test editor behaviorecho "test" > /tmp/test.txt$EDITOR /tmp/test.txt# Should wait for editor to close before continuingIntegration Examples
Section titled “Integration Examples”Development Environment
Section titled “Development Environment”# .env.local or shell profileexport KILN_CONFIG_FILE=./config/dev-kiln.tomlexport KILN_PRIVATE_KEY_FILE=~/.kiln/dev.keyexport EDITOR="code --wait"Production Deployment
Section titled “Production Deployment”# Deployment scriptexport KILN_CONFIG_FILE=/etc/kiln/production.tomlexport KILN_PRIVATE_KEY_FILE=/secrets/deploy.keyexport TMPDIR=/dev/shm # Memory-backed for security
kiln run --file production -- ./deploy.shMulti-User System
Section titled “Multi-User System”# System administrator setupexport KILN_CONFIG_FILE=/etc/kiln/system.toml
# Individual user overrideexport KILN_PRIVATE_KEY_FILE=~/.kiln/personal.keyTesting Framework
Section titled “Testing Framework”# Test script setupexport KILN_CONFIG_FILE=test/fixtures/test.tomlexport KILN_PRIVATE_KEY_FILE=test/fixtures/test.key
# Run tests with isolated environmentkiln run --file test -- npm testBest Practices
Section titled “Best Practices”Environment Isolation
Section titled “Environment Isolation”Use different variables for different contexts:
# Developmentexport KILN_CONFIG_FILE=dev.tomlexport KILN_PRIVATE_KEY_FILE=~/.kiln/dev.key
# Productionexport KILN_CONFIG_FILE=prod.tomlexport KILN_PRIVATE_KEY_FILE=/secure/prod.keyScript Integration
Section titled “Script Integration”Set variables at script level for consistency:
#!/bin/bashset -euo pipefail
# Set kiln environmentexport KILN_CONFIG_FILE="${KILN_CONFIG_FILE:-./kiln.toml}"export KILN_PRIVATE_KEY_FILE="${KILN_PRIVATE_KEY_FILE:-~/.kiln/kiln.key}"
# Use kiln commandskiln info --verifykiln run --file production -- ./deploy.shError Handling
Section titled “Error Handling”Validate environment before operations:
# Check required variables are set: "${KILN_PRIVATE_KEY_FILE:?KILN_PRIVATE_KEY_FILE must be set}": "${KILN_CONFIG_FILE:?KILN_CONFIG_FILE must be set}"
# Verify files existif [[ ! -r "$KILN_PRIVATE_KEY_FILE" ]]; then echo "Cannot read private key: $KILN_PRIVATE_KEY_FILE" >&2 exit 1fi