Uninstall is an activation too: removing the executable or its indexes * while a daemon generation is starting/running would leave live sessions on * a partially removed installation. Keep every filesystem mutation inside * the same startup-lock + lifetime-reservation guard as install/update. */
| 12873 | * a partially removed installation. Keep every filesystem mutation inside |
| 12874 | * the same startup-lock + lifetime-reservation guard as install/update. */ |
| 12875 | static int cli_uninstall_activate(void *opaque) { |
| 12876 | cli_uninstall_activation_t *activation = opaque; |
| 12877 | if (!activation || !activation->home) { |
| 12878 | return CLI_TRUE; |
| 12879 | } |
| 12880 | |
| 12881 | cli_config_follow_begin(activation->home); |
| 12882 | if (activation->agents.claude_code) { |
| 12883 | uninstall_claude_code(activation->home, activation->bin_path, activation->dry_run); |
| 12884 | } |
| 12885 | uninstall_cli_agents(&activation->agents, activation->home, activation->dry_run); |
| 12886 | uninstall_editor_agents(&activation->agents, activation->home, activation->dry_run); |
| 12887 | uninstall_additional_agents(&activation->agents, activation->home, activation->dry_run); |
| 12888 | uninstall_agent_client_registry(activation->home, activation->dry_run); |
| 12889 | cbm_config_edit_path_follow_clear(); |
| 12890 | |
| 12891 | /* Agent-config failures are collected, never a gate: an entry the editors |
| 12892 | * refuse to touch (a symlinked config, a foreign file, a malformed |
| 12893 | * document) is the user's to fix by hand, and leaving a 300 MB executable |
| 12894 | * plus every index behind because of it is the data-loss shape of #1954. |
| 12895 | * The indexes and the executable go now; the failures are listed at the |
| 12896 | * end and decide the exit code. */ |
| 12897 | |
| 12898 | #ifdef _WIN32 |
| 12899 | /* #2117: install registers the install directory in the persistent |
| 12900 | * current-user PATH; uninstall must take it back out, or every cycle leaves |
| 12901 | * a stale entry and the PATH grows without bound. Remove only our segment. |
| 12902 | * A registry hiccup here is a warning, never a hard failure: the user is |
| 12903 | * removing the tool and must not be blocked from finishing over a cosmetic |
| 12904 | * PATH edit. Suppress the mutation under the test-ops seam exactly as |
| 12905 | * install does, so the CLI suite never touches the developer's real PATH. */ |
| 12906 | if (activation->bin_path && activation->bin_path[0]) { |
| 12907 | const char *slash = strrchr(activation->bin_path, '/'); |
| 12908 | const char *backslash = strrchr(activation->bin_path, '\\'); |
| 12909 | if (backslash && (!slash || backslash > slash)) { |
| 12910 | slash = backslash; |
| 12911 | } |
| 12912 | if (slash && slash != activation->bin_path) { |
| 12913 | size_t dir_len = (size_t)(slash - activation->bin_path); |
| 12914 | char bin_dir[CLI_BUF_1K]; |
| 12915 | if (dir_len < sizeof(bin_dir)) { |
| 12916 | memcpy(bin_dir, activation->bin_path, dir_len); |
| 12917 | bin_dir[dir_len] = '\0'; |
| 12918 | int path_rc = cli_remove_windows_user_path( |
| 12919 | bin_dir, activation->dry_run || g_cli_activation_test_ops_set); |
| 12920 | if (path_rc == CLI_OK) { |
| 12921 | printf(activation->dry_run ? "\nWould remove %s from the current-user PATH\n" |
| 12922 | : "\nRemoved %s from the current-user PATH\n", |
| 12923 | bin_dir); |
| 12924 | } else if (path_rc == CLI_ERR) { |
| 12925 | (void)fprintf(stderr, |
| 12926 | "warning: could not update the current-user PATH; %s may " |
| 12927 | "remain on it\n", |
| 12928 | bin_dir); |
| 12929 | } |
| 12930 | } |
| 12931 | } |
| 12932 | } |
no test coverage detected