Is the running binary owned by an external package manager rather than by us? * * #1566: cbm's installer does two separable jobs — place the binary (and put its * directory on PATH), and configure the agents. For someone who installed * through mise, Homebrew or nix, the first job is not merely redundant: it drops * a SECOND copy into ~/.local/bin that shadows the managed one depending on PAT
| 10907 | * best-effort — the behaviour does not depend on recognising it, only the |
| 10908 | * wording does. */ |
| 10909 | static const char *cli_external_manager_name(const char *self_path) { |
| 10910 | if (!self_path || !self_path[0]) { |
| 10911 | return NULL; |
| 10912 | } |
| 10913 | if (strstr(self_path, "/mise/") || strstr(self_path, "/.mise/")) { |
| 10914 | return "mise"; |
| 10915 | } |
| 10916 | if (strstr(self_path, "/Cellar/") || strstr(self_path, "/homebrew/") || |
| 10917 | strstr(self_path, "/linuxbrew/")) { |
| 10918 | return "Homebrew"; |
| 10919 | } |
| 10920 | if (strstr(self_path, "/nix/store/")) { |
| 10921 | return "nix"; |
| 10922 | } |
| 10923 | if (strstr(self_path, "/.asdf/")) { |
| 10924 | return "asdf"; |
| 10925 | } |
| 10926 | if (strstr(self_path, "/.cargo/bin/")) { |
| 10927 | return "cargo"; |
| 10928 | } |
| 10929 | #ifdef __FreeBSD__ |
| 10930 | /* FreeBSD ports/pkg install under ${LOCALBASE} (default /usr/local). pkg owns |
| 10931 | * that file, so install must not drop a second copy in ~/.local/bin or edit a |
| 10932 | * shell rc, and update must defer to pkg(8). Anchor at the start so a manual |
| 10933 | * `install --dir=/opt/...` elsewhere is still treated as ours; --force-binary |
| 10934 | * is the escape hatch for anyone who really does self-manage that prefix. |
| 10935 | * |
| 10936 | * LOCALBASE is configurable, so the port passes its real PREFIX via |
| 10937 | * -DCBM_PKG_PREFIX; when it is absent we fall back to the documented default. */ |
| 10938 | #ifdef CBM_PKG_PREFIX |
| 10939 | if (strncmp(self_path, CBM_PKG_PREFIX "/bin/", sizeof(CBM_PKG_PREFIX "/bin/") - 1) == 0 || |
| 10940 | strncmp(self_path, CBM_PKG_PREFIX "/sbin/", sizeof(CBM_PKG_PREFIX "/sbin/") - 1) == 0) { |
| 10941 | return "FreeBSD pkg"; |
| 10942 | } |
| 10943 | #else |
| 10944 | if (strncmp(self_path, "/usr/local/bin/", 15) == 0 || |
| 10945 | strncmp(self_path, "/usr/local/sbin/", 16) == 0) { |
| 10946 | return "FreeBSD pkg"; |
| 10947 | } |
| 10948 | #endif |
| 10949 | #endif |
| 10950 | return NULL; |
| 10951 | } |
| 10952 | |
| 10953 | #ifdef CBM_CLI_ENABLE_TEST_API |
| 10954 | const char *cbm_cli_external_manager_name_for_testing(const char *self_path) { |
no outgoing calls
no test coverage detected