k1tbyte/Wand-Enhancer · error · FileNotFoundException
Required workspace artifact not found: {Path.Combine(segment
Error message
Required workspace artifact not found: {Path.Combine(segments)} What it means
FindWorkspacePath walks up from the assembly's directory looking for a relative path built from the given segments (used for web-panel/dist). It is only reached as a dev fallback when CopyEmbeddedDirectory(EmbeddedRemotePanelDistPrefix) returned 0 — i.e. no remote-panel/dist resources are embedded in the assembly — and the on-disk workspace path also cannot be located.
Source
Thrown at WandEnhancer/Core/Enhancer.cs:244
return searchHints.Any(searchHint => source.IndexOf(searchHint, StringComparison.Ordinal) >= 0);
}
private static string FindWorkspacePath(params string[] segments)
{
string current = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
while (!string.IsNullOrEmpty(current))
{
string candidate = Path.Combine(new[] { current }.Concat(segments).ToArray());
if (Directory.Exists(candidate) || File.Exists(candidate))
{
return candidate;
}
current = Directory.GetParent(current)?.FullName;
}
throw new FileNotFoundException($"Required workspace artifact not found: {Path.Combine(segments)}");
}
internal static void CopyDirectory(string sourceDir, string destinationDir)
{
Directory.CreateDirectory(destinationDir);
foreach (var directory in Directory.GetDirectories(sourceDir, "*", SearchOption.AllDirectories))
{
var relativePath = directory.Substring(sourceDir.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
Directory.CreateDirectory(Path.Combine(destinationDir, relativePath));
}
foreach (var file in Directory.GetFiles(sourceDir, "*", SearchOption.AllDirectories))
{
var relativePath = file.Substring(sourceDir.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
var destinationPath = Path.Combine(destinationDir, relativePath);
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath) ?? destinationDir);
File.Copy(file, destinationPath, true);View on GitHub (pinned to 643c8f8b62)
Solutions
- Run the patcher from within the repo workspace where web-panel/dist exists, OR
- Ensure the build embeds remote-panel/dist resources into the assembly (check the EmbeddedResource / LogicalName entries in the .csproj).
- Run `cd web-panel && pnpm run build` first so web-panel/dist is populated.
- Place web-panel/dist at or above the patcher exe's directory.
Defensive patterns
Strategy: validation
Validate before calling
// Pre-resolve the workspace dist path; fall back gracefully
string distPath = Path.Combine(executableDir, "web-panel", "dist");
if (!Directory.Exists(distPath) && !HasEmbeddedRemotePanelResources())
throw new InvalidOperationException("web-panel/dist not found and no embedded resources; run `cd web-panel && pnpm run build`."); Try / catch
try { enhancer.Patch(); }
catch (FileNotFoundException ex) when (ex.Message.Contains("Required workspace artifact")) {
// instruct user to build web-panel or run from repo root
} Prevention
- Always embed remote-panel/dist in release builds so FindWorkspacePath is never needed.
- Document that dev runs must execute from the repo root.
- Add a preflight check that either embedded resources or workspace dist exist.
When it happens
Trigger: InjectRemotePanelFiles at Enhancer.cs:397-399: CopyEmbeddedDirectory("remote-panel/dist/", targetRoot) == 0, so it calls FindWorkspacePath("web-panel", "dist"); the walk-up from Assembly.Location never finds a web-panel/dist directory.
Common situations: Running a shipped/published exe outside the repo without embedding remote-panel resources; invoking the patcher from a copied location not nested under the workspace root; the .csproj does not embed the dist tree so the dev fallback is required but unavailable.
Related errors
- Embedded resource not found: {resourceName}
- [ENHANCER] Remote bridge artifact is missing. Run `cd web-pa
- [ENHANCER] Remote renderer script artifacts are missing. Run
- [ENHANCER] Proxy DLL resource not found
AI-assisted analysis of k1tbyte/Wand-Enhancer@643c8f8b62 (2026-08-13).
Data as JSON: /api/errors/d8ecede212a3a961.
Report an issue: GitHub.