d2lang/d2 · warning
chromium installation cancelled by user
Error message
chromium installation cancelled by user
What it means
When the user answers anything other than y/yes to the Chromium install confirmation, InitPlaywrightWithPrompt deliberately returns this error. It is a controlled user-declined outcome, not a malfunction.
Source
Thrown at lib/png/png.go:116
if os.Getenv("CI") != "" {
return InitPlaywright()
}
// Just try running first. This only works if drivers and browsers are already installed
pw, err := playwright.Run()
if err == nil {
return startPlaywright(pw)
}
fmt.Print("D2 needs to install Chromium v149.0.7827.55 to render non-SVG images. Continue? (y/N): ")
reader := bufio.NewReader(os.Stdin)
response, err := reader.ReadString('\n')
if err != nil {
return Playwright{}, fmt.Errorf("failed to read user input: %w", err)
}
response = strings.TrimSpace(strings.ToLower(response))
if response != "y" && response != "yes" {
return Playwright{}, fmt.Errorf("chromium installation cancelled by user")
}
return InitPlaywright()
}
type timeoutSetter interface {
SetDefaultTimeout(float64)
SetDefaultNavigationTimeout(float64)
}
func configureTimeout(target timeoutSetter) {
seconds, ok := env.Timeout()
if !ok {
return
}
if seconds < 0 {
seconds = 0
}View on GitHub (pinned to 0d69dca6f5)
Solutions
- Re-run and answer y or yes to proceed with installation
- Set CI=1 to skip the prompt entirely if automation should always install
- Pre-install Chromium out-of-band and use a path that does not prompt
- If declined intentionally, fall back to SVG output instead of PNG rendering
Example fix
// before
pw, err := InitPlaywrightWithPrompt() // error: cancelled by user
// after
if err != nil && strings.Contains(err.Error(), "cancelled by user") {
log.Println("PNG rendering skipped; export SVG instead")
return renderSVG()
} Defensive patterns
Strategy: try-catch
Validate before calling
// no pre-check possible; user decision at runtime fmt.Fprintln(os.Stderr, "Chromium download (~150MB) required")
Type guard
func isUserCancelled(err error) bool { return strings.Contains(err.Error(), "cancelled by user") } Try / catch
pw, err := InitPlaywrightWithPrompt()
if err != nil {
if isUserCancelled(err) {
return renderSVG() // graceful fallback
}
return err
} Prevention
- Document the y/N prompt in your tool's docs
- Offer SVG output as a no-install alternative
- Set CI=1 to auto-proceed in automation
- Pre-install Chromium to avoid the prompt entirely
When it happens
Trigger: User types anything except y or yes (case-insensitive, trimmed) at the 'Continue? (y/N)' prompt during InitPlaywrightWithPrompt().
Common situations: User accidentally presses Enter (default is No); scripted input containing unexpected text; user declines a large download on metered connections.
Related errors
- no color stops in gradient
- cannot read a directory
- %s is not a supported format. Supported formats are: %s
- failed to fully compile (partial render written) %s: %w
- failed to compile %s: %w
AI-assisted analysis of d2lang/d2@0d69dca6f5 (2026-08-31).
Data as JSON: /api/errors/b56c873871b5fdf0.
Report an issue: GitHub.