k1tbyte/Wand-Enhancer · error · Exception

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

Error message

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

What it means

After PatchAsar + InjectRemotePanelFiles, AsarCreator(_unpackedPath, _asarPath, CreateOptions{Unpack=^static\\unpacked.*$}).CreatePackageWithOptions() threw; the exception is wrapped with its inner Message. This is the repack that re-bundles the patched unpacked tree back into app.asar.

Source

Thrown at WandEnhancer/Core/Enhancer.cs:498

            }
            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();
            
            _logger("[ENHANCER] Done!", ELogType.Success);
        }
    }
}

View on GitHub (pinned to 643c8f8b62)

Solutions

  1. Confirm Wand.exe is fully terminated (Task Manager) before re-running.
  2. Free disk space on the install volume.
  3. Read the inner exception message for the concrete cause.
  4. Run the patcher as administrator if app.asar is access-denied.
  5. Exclude the Wand install directory in antivirus.
Defensive patterns

Strategy: try-catch

Validate before calling

// Preflight: nothing should hold app.asar open; ensure free disk space
if (Process.GetProcessesByName(_weModConfig.BrandName).Length > 0)
    throw new InvalidOperationException("Wand still running; repack will be blocked.");
if (new DriveInfo(_asarPath).AvailableFreeSpace < 256 * 1024 * 1024)
    throw new InvalidOperationException("Insufficient disk space to repack app.asar.");

Try / catch

try {
    enhancer.Patch();
} catch (Exception ex) when (ex.Message.StartsWith("[ENHANCER] Failed to pack app.asar:")) {
    // inner Message holds AsarSharp cause; ensure Wand closed + disk space, retry once
}

Prevention

When it happens

Trigger: Enhancer.Patch() repack try/catch at Enhancer.cs:489-499: AsarSharp.AsarCreator.CreatePackageWithOptions throws.

Common situations: Wand still holds a handle on app.asar (did not fully exit); antivirus locking the file; disk full; an injected asset is too large; permission denied overwriting app.asar; a locked file under static/unpacked.

Related errors


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