Skip to content

Commit e7bd55f

Browse files
committed
fix for linux
1 parent 9e02ef3 commit e7bd55f

4 files changed

Lines changed: 53 additions & 4 deletions

File tree

src/UniGetUI.PackageEngine.Managers.Cargo/Cargo.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public partial class Cargo : PackageManager
2424
[GeneratedRegex(@"(.+)v(\d+\.\d+\.\d+)\s*v(\d+\.\d+\.\d+)\s*(Yes|No)")]
2525
private static partial Regex UpdateLineRegex();
2626

27+
// Matches "ripgrep v15.1.0:" lines from `cargo install --list`
28+
[GeneratedRegex(@"^([\w-]+)\s+v(\d+\.\d+\.\d+):")]
29+
private static partial Regex InstallListLineRegex();
30+
2731
public Cargo()
2832
{
2933
string cargoCommand = OperatingSystem.IsWindows() ? "cargo.exe" : "cargo";
@@ -186,6 +190,9 @@ protected override void _loadManagerVersion(out string version)
186190
Logger.Error("cargo version error: " + error);
187191
}
188192

193+
public void InvalidateInstalledCache() =>
194+
TaskRecycler<List<Match>>.RemoveFromCache(GetInstalledCommandOutput);
195+
189196
private IReadOnlyList<Package> GetPackages(LoggableTaskType taskType)
190197
{
191198
List<Package> Packages = [];
@@ -217,13 +224,35 @@ private List<Match> GetInstalledCommandOutput()
217224
logger.AddToStdOut(line);
218225
var match = UpdateLineRegex().Match(line);
219226
if (match.Success)
220-
{
221227
output.Add(match);
222-
}
223228
}
224229
logger.AddToStdErr(p.StandardError.ReadToEnd());
225230
p.WaitForExit();
226231
logger.Close(p.ExitCode);
232+
233+
if (output.Count > 0)
234+
return output;
235+
236+
// Fallback: cargo-update is not installed, use the built-in `cargo install --list`.
237+
// No latest-version info is available, so updates won't be detected, but the installed
238+
// packages list will be populated correctly.
239+
using Process fallback = GetProcess(Status.ExecutablePath, "install --list");
240+
IProcessTaskLogger fallbackLogger = TaskLogger.CreateNew(LoggableTaskType.OtherTask, fallback);
241+
fallbackLogger.AddToStdOut("Falling back to `cargo install --list` (cargo-update not available)");
242+
fallback.Start();
243+
while ((line = fallback.StandardOutput.ReadLine()) is not null)
244+
{
245+
fallbackLogger.AddToStdOut(line);
246+
var m = InstallListLineRegex().Match(line);
247+
if (!m.Success) continue;
248+
// Synthesise a match compatible with UpdateLineRegex (same installed and latest version → no update)
249+
var fake = UpdateLineRegex().Match($"{m.Groups[1].Value} v{m.Groups[2].Value} v{m.Groups[2].Value} No");
250+
if (fake.Success)
251+
output.Add(fake);
252+
}
253+
fallbackLogger.AddToStdErr(fallback.StandardError.ReadToEnd());
254+
fallback.WaitForExit();
255+
fallbackLogger.Close(fallback.ExitCode);
227256
return output;
228257
}
229258

src/UniGetUI.PackageEngine.Managers.Cargo/Helpers/CargoPkgOperationHelper.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ protected override OperationVeredict _getOperationResult(
7575
int returnCode
7676
)
7777
{
78-
return returnCode == 0 ? OperationVeredict.Success : OperationVeredict.Failure;
78+
if (returnCode == 0)
79+
{
80+
((Cargo)Manager).InvalidateInstalledCache();
81+
return OperationVeredict.Success;
82+
}
83+
return OperationVeredict.Failure;
7984
}
8085
}

src/UniGetUI.PackageEngine.Managers.Pip/Pip.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,21 @@ protected override void _loadManagerExecutableFile(
431431
out string callArguments
432432
)
433433
{
434+
// On non-Windows, prefer pip3/pip as standalone executables (avoids "No module named pip"
435+
// errors on systems where pip is installed as a command but not as a Python module).
436+
// Fall back to python/python3 + "-m pip" if no standalone pip is found.
437+
if (!OperatingSystem.IsWindows())
438+
{
439+
var pipPaths = CoreTools.WhichMultiple("pip3").Concat(CoreTools.WhichMultiple("pip")).ToList();
440+
if (pipPaths.Count > 0)
441+
{
442+
found = true;
443+
path = pipPaths[0];
444+
callArguments = "";
445+
return;
446+
}
447+
}
448+
434449
var (_found, _path) = GetExecutableFile();
435450
found = _found;
436451
path = _path;

src/UniGetUI.PackageEngine.Managers.Vcpkg/Helpers/VcpkgPkgOperationHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ OperationType operation
2020
{
2121
OperationType.Install => [Manager.Properties.InstallVerb, package.Id],
2222
OperationType.Update => [Manager.Properties.UpdateVerb, package.Id, "--no-dry-run"],
23-
OperationType.Uninstall => [Manager.Properties.UninstallVerb, package.Id],
23+
OperationType.Uninstall => [Manager.Properties.UninstallVerb, package.Id, "--recurse"],
2424
_ => throw new InvalidDataException("Invalid package operation"),
2525
};
2626

0 commit comments

Comments
 (0)