LykosAI/StabilityMatrix · error · FileNotFoundException
Model file no longer exists
Error message
Model file no longer exists
What it means
MoveModelFileAsync throws FileNotFoundException when the model's resolved source path (model.GetFullPath(modelsRoot)) does not exist on disk. The model file was indexed/registered but has since been deleted, moved, or was never present, so the move cannot proceed.
Solutions
- Rescan/refresh the model library so stale entries pointing at deleted files are removed
- Restore the missing file or correct modelsRoot so GetFullPath resolves to an existing path
- Remove the stale model entry from the index before re-importing the file
- Verify File.Exists on the resolved path before calling MoveModelFileAsync
Example fix
// before
await organizationService.MoveModelFileAsync(model, modelsRoot, destDir);
// after
var path = model.GetFullPath(modelsRoot);
if (!File.Exists(path))
{
await libraryService.RescanAsync(); // drop stale entries
return;
}
await organizationService.MoveModelFileAsync(model, modelsRoot, destDir); Defensive patterns
Strategy: validation
Validate before calling
var sourcePath = model.GetFullPath(modelsRoot);
if (!File.Exists(sourcePath))
{
await libraryService.RescanAsync();
return; // or re-import
} Type guard
bool ModelFileExists(LocalModelFile m, string root) => File.Exists(m.GetFullPath(root));
Try / catch
try
{
await organizationService.MoveModelFileAsync(model, modelsRoot, destination);
}
catch (FileNotFoundException ex)
{
logger.LogWarning(ex, "Model file missing: {Path}", ex.FileName);
// rescan library to drop stale entries
} Prevention
- Rescan the library after external file changes
- Confirm correct modelsRoot for each model type
- Verify file existence before moves
When it happens
Trigger: Calling MoveModelFileAsync (directly or via ApplyPlan) with a LocalModelFile whose path under modelsRoot is missing — e.g. after the file was manually deleted, moved by another tool, or the modelsRoot is wrong.
Common situations: User deleted or renamed model files outside Stability Matrix; external symlinks broken after relocating a models folder; wrong modelsRoot passed (e.g. stable-diffusion vs lora root swapped); stale scan index after a folder change.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- File does not exist
- Could not find file
- File ( ) was not found
- Image file does not exist
- Tar file not found.
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/0337d0dbfde427dd.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Avalonia/Services/ModelOrganizationService.cs:82
Template = effectiveTemplate,
ScopePath = scopePath,
IncludeNested = includeNested,
Items = items,
};
}
/// <summary>
/// Moves a single model file into <paramref name="destinationDirectory"/>, keeping its file
/// name and bringing the .cm-info.json / preview / .yaml sidecars along. Rolls back any
/// already-moved sidecars on failure. Throws <see cref="FileTransferExistsException"/> when
/// a destination file already exists.
/// </summary>
public async Task MoveModelFileAsync(LocalModelFile model, string modelsRoot, string destinationDirectory)
{
var sourcePath = model.GetFullPath(modelsRoot);
if (!File.Exists(sourcePath))
{
throw new FileNotFoundException("Model file no longer exists", sourcePath);
}
Directory.CreateDirectory(destinationDirectory);
var targetPath = Path.Combine(destinationDirectory, Path.GetFileName(sourcePath));
var moves = BuildFileMoves(sourcePath, targetPath);
await ApplyFileMovesAsync(moves).ConfigureAwait(false);
}
public async Task<ModelOrganizationApplyResult> ApplyPlan(ModelOrganizationPlan plan)
{
var movedCount = 0;
var skippedCount = plan.Items.Count(item => !item.CanApply);
var conflictCount = plan.ConflictCount;
var errors = new List<string>();
foreach (var item in plan.Items.Where(item => item.CanApply))View on GitHub (pinned to af93d6ef57)