Skip to content

Commit c2214c7

Browse files
committed
Improve uv cache clear error handling with lock detection and combined output
Replace simple stderr-only error reporting with combined stdout/stderr output. Add detection for "currently in-use" lock errors with helpful hint about waiting or using --force flag. Provide fallback message when command fails with no output.
1 parent 00c81d5 commit c2214c7

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

MCPForUnity/Editor/Services/ServerManagementService.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,22 @@ public bool ClearUvxCache()
4141
McpLog.Debug($"uv cache cleared successfully: {stdout}");
4242
return true;
4343
}
44-
else
45-
{
46-
string errorMessage = string.IsNullOrEmpty(stderr)
47-
? "Unknown error"
48-
: stderr;
44+
string combinedOutput = string.Join(
45+
Environment.NewLine,
46+
new[] { stderr, stdout }.Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()));
4947

50-
McpLog.Error($"Failed to clear uv cache using '{uvCommand} {args}': {errorMessage}. Ensure uv is installed, available on PATH, or set an override in Advanced Settings.");
51-
return false;
48+
string lockHint = (!string.IsNullOrEmpty(combinedOutput) &&
49+
combinedOutput.IndexOf("currently in-use", StringComparison.OrdinalIgnoreCase) >= 0)
50+
? "Another uv process may be holding the cache lock; wait a moment and try again or clear with '--force' from a terminal."
51+
: string.Empty;
52+
53+
if (string.IsNullOrEmpty(combinedOutput))
54+
{
55+
combinedOutput = "Command failed with no output. Ensure uv is installed, on PATH, or set an override in Advanced Settings.";
5256
}
57+
58+
McpLog.Error($"Failed to clear uv cache using '{uvCommand} {args}'. Details: {combinedOutput} {(string.IsNullOrEmpty(lockHint) ? string.Empty : lockHint)}");
59+
return false;
5360
}
5461
catch (Exception ex)
5562
{

0 commit comments

Comments
 (0)