LykosAI/StabilityMatrix · error · FileNotFoundException

Tar file not found.

Error message

Tar file not found.

What it means

After the first Extract7Z pass on a .tar.gz, Extract7ZTar expects the inner .tar (archive filename minus .gz) to exist in the extraction directory. If it doesn't, FileNotFoundException('Tar file not found.') is thrown with the expected tar path.

Solutions

  1. Check the message's tarPath and list the extraction directory to see what the first pass actually produced
  2. Verify the archive is a genuine .tar.gz whose inner name matches the outer base name; if not, extract manually in two explicit steps
  3. Re-download and checksum-verify the archive if the first pass extracted nothing
  4. Use Extract7ZAuto or extract the gz and tar stages separately with explicit paths

Example fix

// before
await ArchiveHelper.Extract7ZTar(archivePath, destDir);
// after
var innerTar = Path.Combine(destDir, Path.GetFileNameWithoutExtension(archivePath));
if (!File.Exists(innerTar))
{
    throw new FileNotFoundException($"First pass produced no tar; contents: {string.Join(',', Directory.EnumerateFileSystemEntries(destDir))}", innerTar);
}
Defensive patterns

Strategy: validation

Validate before calling

var expectedTar = Path.Combine(destDir, Path.GetFileNameWithoutExtension(archivePath));
if (!File.Exists(expectedTar))
    throw new FileNotFoundException($"Expected inner tar missing: {expectedTar}", expectedTar);

Try / catch

try { await ArchiveHelper.Extract7ZTar(archivePath, destDir); }
catch (FileNotFoundException ex)
{
    logger.LogError(ex, "Inner tar not produced; inspecting extraction dir");
    var contents = Directory.EnumerateFileSystemEntries(destDir);
    // locate the actual inner tar and extract it manually
}

Prevention

When it happens

Trigger: The gz pass ran but produced no tar at the expected path — wrong inner filename, archive extracted into a subdirectory, first-pass extraction failed silently, or the archive was not actually a gzipped tar.

Common situations: Archives whose inner file name differs from the outer name (e.g. 'pkg-1.2.tar.gz' containing 'package.tar'); extraction directory pre-populated or cleaned concurrently; corrupted download where 7z extracted nothing.

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


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/eb50891b5e26c446. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Core/Helper/ArchiveHelper.cs:192

    /// First extracts the zipped tar, then extracts the tar and removes the tar.
    /// </summary>
    /// <param name="archivePath"></param>
    /// <param name="extractDirectory"></param>
    /// <returns></returns>
    public static async Task<ArchiveInfo> Extract7ZTar(string archivePath, string extractDirectory)
    {
        if (!archivePath.EndsWith(".tar.gz"))
        {
            throw new ArgumentException("Archive must be a zipped tar.");
        }
        // Extract the tar.gz to tar
        await Extract7Z(archivePath, extractDirectory).ConfigureAwait(false);

        // Extract the tar
        var tarPath = Path.Combine(extractDirectory, Path.GetFileNameWithoutExtension(archivePath));
        if (!File.Exists(tarPath))
        {
            throw new FileNotFoundException("Tar file not found.", tarPath);
        }

        try
        {
            return await Extract7Z(tarPath, extractDirectory).ConfigureAwait(false);
        }
        finally
        {
            // Remove the tar
            if (File.Exists(tarPath))
            {
                File.Delete(tarPath);
            }
        }
    }

    /// <summary>
    /// Extracts with auto handling of tar.gz files.

View on GitHub (pinned to af93d6ef57)