Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Commit 5d34393

Browse files
authored
feat: enhance podman uninstallation process on Linux (#686)
- Added comprehensive cleanup of podman containers, pods, and images - Implemented removal of podman configuration folders - Improved error handling during uninstallation - Restored electron app path import for home directory access
1 parent ef9ab25 commit 5d34393

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

src/main/podman/uninstall/uninstallOnLinux.ts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { app } from 'electron';
12
import { reportEvent } from '../../events';
23
import { execAwait } from '../../execHelper';
3-
// import { app } from 'electron';
44
import logger from '../../logger';
55
import {
66
type PackageManager,
@@ -19,7 +19,44 @@ const uninstallOnLinux = async (): Promise<boolean | { error: string }> => {
1919
logger.info('Uninstalling podman...');
2020
try {
2121
// Returns /Users/<user> (Ex. /Users/johns)
22-
// const userHome = app.getPath('home');
22+
const userHome = app.getPath('home');
23+
24+
// First cleanup containers and pods
25+
try {
26+
// Stop and remove all containers
27+
await execAwait('podman stop -a', { log: true });
28+
await execAwait('podman rm -af', { log: true });
29+
30+
// Remove all pods
31+
await execAwait('podman pod rm -af', { log: true });
32+
33+
// Remove all images
34+
await execAwait('podman rmi -af', { log: true });
35+
36+
logger.info('Successfully cleaned up all podman containers, pods and images');
37+
} catch (cleanupErr) {
38+
logger.error('Error during container cleanup, continuing with uninstall:', cleanupErr);
39+
}
40+
41+
// Remove podman configuration folders
42+
const foldersToDelete = [
43+
`${userHome}/.config/containers`,
44+
`${userHome}/.local/share/containers`,
45+
`${userHome}/.ssh/*podman*`,
46+
'/usr/local/podman',
47+
];
48+
49+
try {
50+
const rmCommand = `rm -rf ${foldersToDelete.join(' ')}`;
51+
await execAwait(rmCommand, {
52+
log: true,
53+
sudo: true,
54+
});
55+
logger.info('Successfully removed podman configuration folders');
56+
} catch (rmErr) {
57+
logger.error('Error removing configuration folders:', rmErr);
58+
// Continue with uninstall even if folder removal fails
59+
}
2360

2461
// 1. (applies to mac, also linux?) This can throw return an error if a file or folder doesn't exist.
2562
// This is ok, because it will still delete the other folders that do exist.
@@ -42,7 +79,7 @@ const uninstallOnLinux = async (): Promise<boolean | { error: string }> => {
4279
log: true,
4380
sudo: true,
4481
});
45-
logger.info(`${uninstallScript} stdout, stderr ${stdout} ${stderr}`);
82+
logger.info(`${uninstallScript} stdout, stderr ${stdout} ${stderr}`);
4683
return true;
4784
} catch (err: any) {
4885
logger.error(err);

0 commit comments

Comments
 (0)