JosefNemec/Playnite · critical · Exception
Database path cannot be empty.
Error message
Database path cannot be empty.
What it means
Thrown as a generic Exception by GameDatabase.OpenDatabase() when DatabasePath is null or empty. DatabasePath is the filesystem directory where the game database resides; it must be set before OpenDatabase is called. This is a configuration/initialization contract violation.
Source
Thrown at source/Playnite/Database/GameDatabase.cs:506
else if (path.Contains("%AppData%", StringComparison.OrdinalIgnoreCase))
{
return path?.Replace("%AppData%", Environment.ExpandEnvironmentVariables("%AppData%"), StringComparison.OrdinalIgnoreCase);
}
else if (!Paths.IsFullPath(path))
{
return Path.GetFullPath(path);
}
else
{
return path;
}
}
public void OpenDatabase()
{
if (string.IsNullOrEmpty(DatabasePath))
{
throw new Exception("Database path cannot be empty.");
}
var dbExists = File.Exists(DatabaseFileSettingsPath);
logger.Info("Opening db " + DatabasePath);
if (!FileSystem.CanWriteToFolder(DatabasePath))
{
throw new Exception($"Can't write to \"{DatabasePath}\" folder.");
}
// This fixes an issue where people mess up their library with custom scripts
// which create collection files instead of directories :|
if (File.Exists(FilesDirectoryPath))
{
File.Delete(FilesDirectoryPath);
}
if (!dbExists)
View on GitHub (pinned to 5911f4e964)
Solutions
- Set DatabasePath to a valid directory before calling OpenDatabase: gameDatabase.DatabasePath = @"C:\Games\Playnite\database".
- In normal (installed) mode, ensure Playnite's settings file is intact and the database path is configured in %AppData%\Playnite.
- In portable mode, ensure the portable directory is writable and the startup logic correctly resolves the database path.
- Reset Playnite settings to defaults if the settings file is corrupt, then reconfigure the database location.
Example fix
// before — calling OpenDatabase without setting path
gameDatabase.OpenDatabase(); // throws if DatabasePath is empty
// after — ensure path is set
gameDatabase.DatabasePath = PlaynitePaths.DatabaseDir;
if (string.IsNullOrEmpty(gameDatabase.DatabasePath))
throw new InvalidOperationException("Database path not configured.");
gameDatabase.OpenDatabase(); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(gameDatabase.DatabasePath))
{
gameDatabase.DatabasePath = PlaynitePaths.DatabaseDir;
if (string.IsNullOrEmpty(gameDatabase.DatabasePath))
throw new InvalidOperationException("Database path could not be resolved.");
} Prevention
- Initialize DatabasePath during application startup before any database operations.
- Add a startup health check that verifies DatabasePath is set and the directory exists.
- Use PlaynitePaths constants to derive the default path consistently.
When it happens
Trigger: OpenDatabase is called before DatabasePath has been configured. The database path was cleared by a settings reset, a failed migration, or a corrupt settings file. A fresh Playnite install where the path initialization code did not run.
Common situations: First launch where path initialization failed or was skipped. Settings file corruption cleared the DatabasePath. A portable mode misconfiguration. A plugin or script cleared the path. Moving the database directory manually without updating settings.
Related errors
- Backup output path not specified!
- Emulator not found.
- Can't write to "{DatabasePath}" folder.
- Database version {Settings.Version} is not supported.
- Database must be migrated before opening.
AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13).
Data as JSON: /api/errors/71981af326188937.
Report an issue: GitHub.