Skip to content

fix: make which available for R (bioconda) post-links in conda v2 builds#1070

Merged
pditommaso merged 1 commit into
masterfrom
add-which-tool-conda-templates
Jul 6, 2026
Merged

fix: make which available for R (bioconda) post-links in conda v2 builds#1070
pditommaso merged 1 commit into
masterfrom
add-which-tool-conda-templates

Conversation

@pditommaso

@pditommaso pditommaso commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Problem

Conda containers with R/bioconductor packages (e.g. the nf-core rnaseq TXIMETA_TXIMPORT step, which installs bioconductor-tximeta) build successfully but fail at runtime:

Loading required package: GenomeInfoDb
Error: package or namespace load failed for 'GenomeInfoDb':
  there is no package called 'GenomeInfoDbData'

Root cause

Bioconductor data packages (GenomeInfoDbData, etc.) don't ship their payload in the conda package — a conda post-link script (post-link.shinstallBiocDataPackage.sh) downloads it and runs R CMD INSTALL at install time.

That R CMD INSTALL starts an R session, and bioconda r-base shells out to /usr/bin/which (absolute path) during utils .onLoad — it ignores $PATH and $R_WHICH. The v2 build image mambaorg/micromamba:2-amazon2023 has no /usr/bin/which, so R can't start, the post-link fails, and the data package is never installed. The post-link failure is non-fatal to micromamba install, so the build "succeeds" and produces a broken image.

This is why simply installing conda-forge::which into /opt/conda/bin was not enough — R only looks at /usr/bin/which.

Fix

In the conda micromamba-v2 build stage (as root), symlink the conda which to /usr/bin/which before the user's packages are installed, so bioconda post-link scripts can run R:

FROM {{mamba_image}} AS build
USER root
...
RUN micromamba install -y -n base conda-forge::which \
    && ln -sf "$MAMBA_ROOT_PREFIX/bin/which" /usr/bin/which \
    && (micromamba install -y -n base -f /tmp/conda.yml ...) ...

Applied to all four conda-micromamba-v2 templates (dockerfile + singularityfile, conda-file + conda-packages). The pixi templates also get which as a base package for consistency, though their *-noble build image already provides a system which. The legacy micromamba v1 template is unaffected (its Debian-based image ships which).

Verification

Reproduced and fixed locally with real Docker builds on amazon2023:

  • Before: R CMD INSTALL post-link fails (.onLoad failed ... error in running command), GenomeInfoDbData absent, runtime load fails.
  • After: post-link succeeds; final image runs library(SummarizedExperiment); library(tximport) → OK.

Unit tests updated: TemplateUtilsTest, ContainerHelperTest (+ CondaHelperTest/PixiHelperTest contains-checks) pass.

Refs: https://community.seqera.io/t/which-is-missing-in-recent-seqera-containers/2718

🤖 Generated with Claude Code

@pditommaso
pditommaso force-pushed the add-which-tool-conda-templates branch from dc5be2e to b520b25 Compare July 3, 2026 06:15
@pditommaso pditommaso changed the title fix: include which tool in conda micromamba-v2 and pixi templates fix: include which tool in conda micromamba-v2 and pixi builds Jul 3, 2026
@pditommaso
pditommaso requested a review from munishchouhan July 3, 2026 07:34
Comment thread src/main/groovy/io/seqera/wave/util/CondaHelper.groovy Outdated
@pditommaso
pditommaso force-pushed the add-which-tool-conda-templates branch from 06d70d6 to af83d37 Compare July 3, 2026 08:39
@pditommaso pditommaso changed the title fix: include which tool in conda micromamba-v2 and pixi builds fix: install which before user packages in conda v2 and pixi templates Jul 3, 2026
@pditommaso
pditommaso requested a review from munishchouhan July 3, 2026 12:50
@pditommaso pditommaso changed the title fix: install which before user packages in conda v2 and pixi templates fix: make which available for R (bioconda) post-links in conda v2 builds Jul 3, 2026
…uilds

Conda containers with R/bioconductor packages built fine but failed at
runtime with "there is no package called 'GenomeInfoDbData'".

Root cause: bioconductor data packages install their payload via a conda
post-link script that runs `R CMD INSTALL`, and bioconda `r-base` shells
out to the absolute path /usr/bin/which during utils .onLoad (it ignores
$PATH and $R_WHICH). The micromamba:2-amazon2023 build image has no
/usr/bin/which, so R fails to start, the post-link fails, and the data
package is silently not installed. The post-link failure is non-fatal to
`micromamba install`, so the build produces a broken image.

Fix: in the conda micromamba-v2 build stage (as root) symlink the conda
`which` to /usr/bin/which before installing the user's packages, so
bioconda post-link scripts can run R. Applied to all four v2 templates.
The pixi templates also install `which` as a base package (their *-noble
build image already provides a system which). The legacy micromamba v1
template is unaffected (Debian-based image ships which).

Verified with real Docker builds on amazon2023: bioconductor-tximeta
installs GenomeInfoDbData and the final image loads SummarizedExperiment
and tximport.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pditommaso
pditommaso force-pushed the add-which-tool-conda-templates branch from 9f2de82 to 153982a Compare July 3, 2026 15:00
@pditommaso
pditommaso merged commit 417e43a into master Jul 6, 2026
4 checks passed
@pditommaso
pditommaso deleted the add-which-tool-conda-templates branch July 6, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants