diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-10-21 11:49:12 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-10-21 11:49:12 -0400 |
commit | f954efd16b99520720d05abde5ec8ff741faa2dd (patch) | |
tree | b1d637f245797ec0da2dace1a4b5e2ff69500459 | |
parent | 62a3bc3a1f33625527cbc039531cfe8b42916d91 (diff) | |
download | stasis-f954efd16b99520720d05abde5ec8ff741faa2dd.tar.gz |
Update conda_provides:
* Avoid false positives by returning early when the spec is empty
* Remove --use-index-cache. The remote channel must always be checked (conda is extremely slow to read its own channel data, so expect abnormally long delays on first-run)
-rw-r--r-- | src/lib/core/conda.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c index c77a132..25069f8 100644 --- a/src/lib/core/conda.c +++ b/src/lib/core/conda.c @@ -443,6 +443,15 @@ char *conda_get_active_environment() { int conda_provides(const char *spec) { struct Process proc; memset(&proc, 0, sizeof(proc)); + + // Short circuit: + // Running "mamba search" without an argument will print every package in + // all channels, then return "found". Prevent this. + // No data implies "not found". + if (isempty((char *) spec)) { + return 0; + } + strcpy(proc.f_stdout, "/dev/null"); strcpy(proc.f_stderr, "/dev/null"); @@ -450,12 +459,12 @@ int conda_provides(const char *spec) { // conda_exec() expects the program output to be visible to the user. // For this operation we only need the exit value. char cmd[PATH_MAX] = {0}; - snprintf(cmd, sizeof(cmd) - 1, "mamba search --use-index-cache %s", spec); + snprintf(cmd, sizeof(cmd) - 1, "mamba search %s", spec); if (shell(&proc, cmd) < 0) { fprintf(stderr, "shell: %s", strerror(errno)); return -1; } - return proc.returncode == 0; + return proc.returncode == 0; // 0=not_found, 1=found } int conda_index(const char *path) { |