LykosAI/StabilityMatrix · critical · Exception
Could not find library after setting path
Error message
Could not find library after setting path
What it means
During startup, DoSettingsCheck attempts to locate the Stability Matrix library directory via settingsManager.TryFindLibrary. If no library is found, it shows a path selection dialog and retries; if the retry also fails, it throws this generic Exception because the app cannot function without a library.
Solutions
- Re-launch and complete the library path selection dialog, choosing the folder containing (or where you want) the Stability Matrix library.
- Verify the selected directory contains the library marker (e.g. .stabilitymatrix) or let the app create a new library there.
- Check read/write permissions on the chosen directory (especially under Program Files or network shares).
- If a portable data folder was moved, restore it to the expected location next to the executable.
Example fix
// before: dialog cancelled, exception thrown
await ShowPathSelectionDialog();
if (!settingsManager.TryFindLibrary()) throw new Exception("Could not find library after setting path");
// after: keep prompting until a valid library is chosen
while (!settingsManager.TryFindLibrary()) { if (!await ShowPathSelectionDialog()) return; } Defensive patterns
Strategy: try-catch
Validate before calling
if (!settingsManager.TryFindLibrary())
{
var ok = await ShowPathSelectionDialog();
if (!ok || !settingsManager.TryFindLibrary()) return; // abort startup gracefully
} Type guard
static bool HasUsableLibrary(ISettingsManager s) =>
s.TryFindLibrary() && Directory.Exists(s.LibraryDir); Try / catch
try { await vm.DoSettingsCheck(); }
catch (Exception ex) when (ex.Message == "Could not find library after setting path")
{
logger.Warning(ex, "No library configured; prompting user again");
await ShowLibrarySetupFlow();
} Prevention
- Complete the first-run library setup instead of cancelling the dialog.
- Keep the library marker file intact and the folder accessible.
- Avoid placing the library in permission-restricted locations.
- Back up and restore settings/library paths together when migrating.
When it happens
Trigger: App startup (OnLoaded -> DoSettingsCheck) when no existing library is found and the user's path selection dialog flow still leaves TryFindLibrary returning false (cancelled dialog, selected folder not a valid library, unwritable path).
Common situations: First launch where the user cancels the folder picker; user picks an arbitrary folder that isn't a Stability Matrix library; portable-mode data folder missing or moved; permissions prevent reading the library marker file at the chosen location.
Related errors
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/46a0f52112c644a8.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix/ViewModels/MainWindowViewModel.cs:147
var updateWindow = new UpdateWindow(updateWindowViewModel)
{
Owner = Application.Current.MainWindow
};
updateWindow.ShowDialog();
}
private async Task DoSettingsCheck()
{
// Check if library path is set
if (!settingsManager.TryFindLibrary())
{
await ShowPathSelectionDialog();
}
// Try to find library again, should be found now
if (!settingsManager.TryFindLibrary())
{
throw new Exception("Could not find library after setting path");
}
// Check if there are old packages, if so show migration dialog
if (settingsManager.GetOldInstalledPackages().Any())
{
var dialog = dialogFactory.CreateDataDirectoryMigrationDialog();
var result = await dialog.ShowAsync();
if (result == ContentDialogResult.None)
{
Application.Current.Shutdown();
}
else if (result == ContentDialogResult.Secondary)
{
var portableMarkerFile = Path.Combine("Data", ".sm-portable");
if (File.Exists(portableMarkerFile))
{
File.Delete(portableMarkerFile);
}View on GitHub (pinned to af93d6ef57)