k1tbyte/Wand-Enhancer · error · Exception

[ENHANCER] Failed to unpack app.asar: {e.Message}

Error message

[ENHANCER] Failed to unpack app.asar: {e.Message}

What it means

AsarExtractor.ExtractAll(_asarPath, _unpackedPath) threw and the exception is wrapped with its inner Message. Per AGENTS.md the extractor intentionally skips in-place self-copies and missing unpacked source entries, so a throw here usually means the asar header/pickle framing is corrupt, the file is not a valid asar, or there is a disk/access error.

Source

Thrown at WandEnhancer/Core/Enhancer.cs:483

            }
            else if (!Directory.Exists(_unpackedPath))
            {
                throw new Exception("[ENHANCER] app.asar.unpacked is missing and no backup exists. Restore the original Wand installation files or reinstall Wand, then patch again.");
            }

            if(!File.Exists(_asarPath))
            {
                throw new Exception("app.asar not found");
            }

            try
            {
                _logger("[ENHANCER] Extracting app.asar...", ELogType.Info);
                AsarExtractor.ExtractAll(_asarPath, _unpackedPath);
            }
            catch (Exception e)
            {
                throw new Exception($"[ENHANCER] Failed to unpack app.asar: {e.Message}");
            }
            
            PatchAsar();
            InjectRemotePanelFiles();

            try
            {
                new AsarCreator(_unpackedPath, _asarPath, new CreateOptions
                {
                    Unpack = new Regex(@"^static\\unpacked.*$")
                }).CreatePackageWithOptions();
            }
            catch (Exception e)
            {
                throw new Exception($"[ENHANCER] Failed to pack app.asar: {e.Message}");
            }
            
            AttachProxyDll();

View on GitHub (pinned to 643c8f8b62)

Solutions

  1. Ensure Wand is fully terminated before patching (Patch calls TryKillProcess first — confirm no Wand.exe remains).
  2. Restore app.asar from app.asar.backup, or reinstall Wand.
  3. Read the inner exception message in the wrapped error for the concrete cause.
  4. Verify disk space and write permissions on _unpackedPath.
Defensive patterns

Strategy: try-catch

Validate before calling

// Best-effort preflight: confirm asar is readable and Wand is not running
if (Process.GetProcessesByName(_weModConfig.BrandName).Length > 0)
    throw new InvalidOperationException("Wand is still running; close it before patching.");
using (var fs = File.OpenRead(_asarPath)) { /* header readable */ }

Try / catch

try {
    enhancer.Patch();
} catch (Exception ex) when (ex.Message.StartsWith("[ENHANCER] Failed to unpack app.asar:")) {
    // inner Message has the AsarSharp cause; restore from app.asar.backup or reinstall
}

Prevention

When it happens

Trigger: Enhancer.Patch() extraction try/catch at Enhancer.cs:476-484: AsarSharp.AsarExtractor.ExtractAll throws.

Common situations: app.asar truncated/corrupted by an interrupted prior patch or disk error; file still locked by a running Wand process; a non-asar file sitting at that path; AsarSharp version incompatibility.

Related errors


AI-assisted analysis of k1tbyte/Wand-Enhancer@643c8f8b62 (2026-08-13). Data as JSON: /api/errors/612788d888549a28. Report an issue: GitHub.