| index c7bad2c..3cf63a5 100644 | | index c7bad2c..3cf63a5 100644 |
| --- a/src/plugin_claudecode_login.c | | --- a/src/plugin_claudecode_login.c |
| +++ b/src/plugin_claudecode_login.c | | +++ b/src/plugin_claudecode_login.c |
| @@ -706,6 +706,30 @@ static void shell_quote_into(const char *in, char *out, size_t outsz) | | @@ -706,6 +706,30 @@ static void shell_quote_into(const char *in, char *out, size_t outsz) |
| 706 | #endif | 706 | #endif |
| 707 | } | 707 | } |
| 708 | | 708 | |
| | 709 | +/* Is <bin> resolvable on this node? POSIX answers through popen's own 127 |
| | 710 | + * ("command not found"). cmd.exe returns 1 for a missing program, which is |
| | 711 | + * indistinguishable from the program's own failure - so on Windows the path is |
| | 712 | + * resolved BEFORE popen with SearchPathA. Without this, a Windows node with no |
| | 713 | + * SCORPIOX CODE reported cli_present:true and "start failed" instead of |
| | 714 | + * cli_unavailable (measured on a real Windows box). */ |
| | 715 | +static int bin_available(const char *bin) |
| | 716 | +{ |
| | 717 | + if (!bin || !*bin) return 0; |
| | 718 | +#if defined(_WIN32) |
| | 719 | + { |
| | 720 | + char full[MAX_PATH]; |
| | 721 | + DWORD n; |
| | 722 | + /* An explicit path is checked directly; a bare name is searched on PATH. */ |
| | 723 | + if (strchr(bin, '\\') || strchr(bin, '/') || strchr(bin, ':')) |
| | 724 | + return file_exists(bin); |
| | 725 | + n = SearchPathA(NULL, bin, ".exe", (DWORD)sizeof(full), full, NULL); |
| | 726 | + return n > 0 && n < (DWORD)sizeof(full); |
| | 727 | + } |
| | 728 | +#else |
| | 729 | + return 1; /* decided by run_capture's own 127 check */ |
| | 730 | +#endif |
| | 731 | +} |
| | 732 | + |
| 709 | /* Run `<bin> <args>` and capture stdout. | 733 | /* Run `<bin> <args>` and capture stdout. |
| 710 | * Returns 1 when the process ran, | 734 | * Returns 1 when the process ran, |
| 711 | * 0 when popen() itself failed, | 735 | * 0 when popen() itself failed, |
| @@ -724,6 +748,7 @@ static int run_capture(const char *bin, const char *args, buf_t *out) | | @@ -724,6 +748,7 @@ static int run_capture(const char *bin, const char *args, buf_t *out) |
| 724 | int rc; | 748 | int rc; |
| 725 | | 749 | |
| 726 | if (!bin || !*bin) return 0; | 750 | if (!bin || !*bin) return 0; |
| | 751 | + if (!bin_available(bin)) return -1; |
| 727 | shell_quote_into(bin, qbin, sizeof(qbin)); | 752 | shell_quote_into(bin, qbin, sizeof(qbin)); |
| 728 | #if defined(_WIN32) | 753 | #if defined(_WIN32) |
| 729 | if (args && *args) snprintf(cmd, sizeof(cmd), "%s %s 2>NUL", qbin, args); | 754 | if (args && *args) snprintf(cmd, sizeof(cmd), "%s %s 2>NUL", qbin, args); |
| 730 | | 755 | |