From bdcf35cfa3d73645cf0658b318787a80a3004257 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 4 Jun 2026 10:24:28 -0400 Subject: delivery_conda_enable populates CondaCapabilities members --- src/lib/delivery/delivery_conda.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/lib/delivery/delivery_conda.c') diff --git a/src/lib/delivery/delivery_conda.c b/src/lib/delivery/delivery_conda.c index 117e6c9..e1a07f1 100644 --- a/src/lib/delivery/delivery_conda.c +++ b/src/lib/delivery/delivery_conda.c @@ -120,7 +120,17 @@ void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { exit(1); } - if (conda_setup_headless()) { + if (conda_capable(&ctx->conda.capabilities)) { + SYSERROR("Conda capability check failed"); + exit(1); + } + + if (!ctx->conda.capabilities.usable) { + SYSERROR("Conda is broken"); + exit(1); + } + + if (conda_setup_headless(&ctx->conda.capabilities)) { // no COE check. this call must succeed. exit(1); } -- cgit From da57037c0fbbe0619bc40ea990dba7f1f6d316a8 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 4 Jun 2026 13:34:58 -0400 Subject: delivery_conda_enable: always pin conda's version to the same version provided by the installer * Some commands upgrade conda whether it is configured to allow the behavior or not --- src/lib/delivery/delivery_conda.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/lib/delivery/delivery_conda.c') diff --git a/src/lib/delivery/delivery_conda.c b/src/lib/delivery/delivery_conda.c index e1a07f1..3938842 100644 --- a/src/lib/delivery/delivery_conda.c +++ b/src/lib/delivery/delivery_conda.c @@ -120,6 +120,30 @@ void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { exit(1); } + char pinned[PATH_MAX]; + snprintf(pinned, sizeof(pinned), "%s/conda-meta/pinned", conda_install_dir); + touch(pinned); + if (errno == ENOENT) { + errno = 0; + } + + char *conda_version = strdup(ctx->conda.installer_version); + if (conda_version) { + char *rev = strpbrk(conda_version, "-"); + if (rev) { + *rev = '\0'; + } + + FILE *pinned_fp = fopen(pinned, "w+"); + if (!pinned_fp) { + SYSERROR("unable to open conda-meta/pinned file for writing: %s", strerror(errno)); + exit(1); + } + fprintf(pinned_fp, "conda=%s\n", conda_version); + fclose(pinned_fp); + guard_free(conda_version); + } + if (conda_capable(&ctx->conda.capabilities)) { SYSERROR("Conda capability check failed"); exit(1); -- cgit From 5c15c56a7e36c26d4e095d30a146e758890424b4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 11 Jun 2026 13:19:43 -0400 Subject: Set mamba-related environment variables --- src/lib/delivery/delivery_conda.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/lib/delivery/delivery_conda.c') diff --git a/src/lib/delivery/delivery_conda.c b/src/lib/delivery/delivery_conda.c index 3938842..e879d1d 100644 --- a/src/lib/delivery/delivery_conda.c +++ b/src/lib/delivery/delivery_conda.c @@ -104,6 +104,7 @@ void delivery_install_conda(char *install_script, char *conda_install_dir) { } void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { + setenv("MAMBA_ROOT_PREFIX", ctx->storage.conda_install_prefix, 1); if (conda_activate(conda_install_dir, "base")) { SYSERROR("conda activation failed"); exit(1); @@ -115,6 +116,7 @@ void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { char rcpath[PATH_MAX]; snprintf(rcpath, sizeof(rcpath), "%s/%s", conda_install_dir, ".condarc"); setenv("CONDARC", rcpath, 1); + setenv("MAMBARC", rcpath, 1); if (runtime_replace(&ctx->runtime.environ, __environ)) { SYSERROR("unable to replace runtime environment after activating conda"); exit(1); -- cgit From 4798135aec35ef84baa43dcc38a3681e490c6c78 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 16 Jun 2026 11:37:28 -0400 Subject: Store conda installation prefix in capabilities structure --- src/lib/delivery/delivery_conda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/delivery/delivery_conda.c') diff --git a/src/lib/delivery/delivery_conda.c b/src/lib/delivery/delivery_conda.c index e879d1d..12eddb7 100644 --- a/src/lib/delivery/delivery_conda.c +++ b/src/lib/delivery/delivery_conda.c @@ -146,7 +146,7 @@ void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { guard_free(conda_version); } - if (conda_capable(&ctx->conda.capabilities)) { + if (conda_capable(&ctx->conda.capabilities, ctx->storage.conda_install_prefix)) { SYSERROR("Conda capability check failed"); exit(1); } -- cgit From b95f5a2fed749f7fe5154927620457385b0292f8 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 16 Jun 2026 11:40:41 -0400 Subject: Passing the conda installation directory to delivery_conda_enable isn't necessary * The delivery context already provides this path --- src/lib/delivery/delivery_conda.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/lib/delivery/delivery_conda.c') diff --git a/src/lib/delivery/delivery_conda.c b/src/lib/delivery/delivery_conda.c index 12eddb7..4f2920e 100644 --- a/src/lib/delivery/delivery_conda.c +++ b/src/lib/delivery/delivery_conda.c @@ -103,18 +103,14 @@ void delivery_install_conda(char *install_script, char *conda_install_dir) { } } -void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { +void delivery_conda_enable(struct Delivery *ctx) { setenv("MAMBA_ROOT_PREFIX", ctx->storage.conda_install_prefix, 1); - if (conda_activate(conda_install_dir, "base")) { - SYSERROR("conda activation failed"); - exit(1); - } // Setting the CONDARC environment variable appears to be the only consistent // way to make sure the file is used. Not setting this variable leads to strange // behavior, especially if a conda environment is already active when STASIS is loaded. char rcpath[PATH_MAX]; - snprintf(rcpath, sizeof(rcpath), "%s/%s", conda_install_dir, ".condarc"); + snprintf(rcpath, sizeof(rcpath), "%s/%s", ctx->storage.conda_install_prefix, ".condarc"); setenv("CONDARC", rcpath, 1); setenv("MAMBARC", rcpath, 1); if (runtime_replace(&ctx->runtime.environ, __environ)) { @@ -122,8 +118,13 @@ void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { exit(1); } + if (conda_activate(ctx->storage.conda_install_prefix, "base")) { + SYSERROR("conda activation failed"); + exit(1); + } + char pinned[PATH_MAX]; - snprintf(pinned, sizeof(pinned), "%s/conda-meta/pinned", conda_install_dir); + snprintf(pinned, sizeof(pinned), "%s/conda-meta/pinned", ctx->storage.conda_install_prefix); touch(pinned); if (errno == ENOENT) { errno = 0; -- cgit