benbjohnson/litestream · error

cannot access database: %w

Error message

cannot access database: %w

What it means

Wraps a non-IsNotExist os.Stat failure on the database path in 'litestream reset'. Fires when the database path cannot be probed due to permission errors or other filesystem failures, so existence cannot be determined.

Source

Thrown at cmd/litestream/reset.go:71

		// Find database config
		for _, dbc := range config.DBs {
			expandedPath := dbc.Path
			if !filepath.IsAbs(expandedPath) {
				expandedPath, _ = filepath.Abs(expandedPath)
			}
			if expandedPath == dbPath {
				dbConfig = dbc
				break
			}
		}
	}

	// If no config found, check if database file exists
	if _, err := os.Stat(dbPath); os.IsNotExist(err) {
		return fmt.Errorf("database does not exist: %s", dbPath)
	} else if err != nil {
		return fmt.Errorf("cannot access database: %w", err)
	}

	// Create DB instance
	var db *litestream.DB
	if dbConfig != nil {
		db, err = NewDBFromConfig(dbConfig)
		if err != nil {
			return fmt.Errorf("cannot create database from config: %w", err)
		}
	} else {
		db = litestream.NewDB(dbPath)
	}

	// Check if meta path exists
	metaPath := db.MetaPath()
	if _, err := os.Stat(metaPath); os.IsNotExist(err) {
		fmt.Printf("No local state to reset for %s\n", dbPath)
		fmt.Printf("Meta directory does not exist: %s\n", metaPath)

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Check permissions on the database path and parent directories
  2. Run as a user with read access to the path
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cmd/litestream/reset.go:71 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/eca6f62aa82efb2d. Report an issue: GitHub.