benbjohnson/litestream · error
cannot expand home directory for sse-customer-key-path: %w
Error message
cannot expand home directory for sse-customer-key-path: %w
What it means
Wraps os.UserHomeDir() failure while expanding a leading '~' in the s3 sse-customer-key-path config option. Fires when the path starts with '~' but the user's home directory cannot be determined (e.g. HOME not set in the environment); the SSE-C key file cannot be located.
Source
Thrown at cmd/litestream/main.go:1696
if c.Concurrency != nil {
client.Concurrency = *c.Concurrency
}
// Apply SSE-C configuration if specified.
if c.SSECustomerKey != "" || c.SSECustomerKeyPath != "" {
client.SSECustomerAlgorithm = c.SSECustomerAlgorithm
if client.SSECustomerAlgorithm == "" {
client.SSECustomerAlgorithm = "AES256"
}
// Read key from file if path is specified, otherwise use direct value.
if c.SSECustomerKeyPath != "" {
keyPath := c.SSECustomerKeyPath
// Expand ~ to home directory
if strings.HasPrefix(keyPath, "~") {
home, err := os.UserHomeDir()
if err != nil {
return nil, fmt.Errorf("cannot expand home directory for sse-customer-key-path: %w", err)
}
keyPath = home + keyPath[1:]
}
keyData, err := os.ReadFile(keyPath)
if err != nil {
return nil, fmt.Errorf("cannot read sse-customer-key-path %q: %w", c.SSECustomerKeyPath, err)
}
client.SSECustomerKey = strings.TrimSpace(string(keyData))
} else {
client.SSECustomerKey = c.SSECustomerKey
}
}
// Apply SSE-KMS configuration if specified.
if c.SSEKMSKeyID != "" {
client.SSEKMSKeyID = c.SSEKMSKeyID
}
View on GitHub (pinned to 4ed7a308f6)
Solutions
- Set HOME (or USERPROFILE on Windows) in the service environment
- Use an absolute path for sse-customer-key-path instead of '~'
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cmd/litestream/main.go:1696 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06).
Data as JSON: /api/errors/be87b5e44cfd671f.
Report an issue: GitHub.