nextflow-io / nextflow-io/nextflow

Add TMPDIR to Singularity/Apptainer auto-mounted directories

Open
#4,587 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

software/singularity
Dominant language
Groovy
Stars
3.5k
Forks
811
Avg merge
2d 11h
Merged PRs (30d)
61

Description

Bug report

This is somewhere between a bug report and a feature request. The current behavior can lead to unexpected consequences, tripping up even experienced users.

Expected behavior and actual behavior

It would be nice if we could use e.g. mktemp inside a container without worrying about bind-mounting directories. Adding $TMPDIR (and maybe $TMP) to the automatically mounted directories with autoMounts = true would accomplish this.

Currently the environment variable TMPDIR gets passed into a Singularity/Apptainer container (which is good) but the corresponding directory is often not accessible from inside the container, even with autoMounts = true. This will lead to an error in e.g. mktemp (or anything else honoring TMPDIR), which can be hard to debug if the user is not conscious that TMPDIR had been set (e.g. by the OS).

Steps to reproduce the problem

Set TMPDIR (either in the OS or in an env scope) to a directory that is not by default mounted by Singularity/Apptainer (e.g. /scratch). Set autoMounts = true in the applicable scope. A mktemp statement in the script section of a process will fail, unless something like runOptions = '-B /scratch' is set for the container engine.

Program output

(Copy and paste here output produced by the failing execution. Please highlight it as a code block. Whenever possible upload the .nextflow.log file.)

Environment
  • Nextflow version: 23.10
  • Java version: any compatible
  • Operating system: any
  • Bash version: any
Additional context

TMP is not POSIX but is often used like TMPDIR, so maybe treat it the same.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the code that handles autoMounts and container bind mounts, then trace how TMPDIR is passed into Singularity/Apptainer. Done means TMPDIR is automatically mounted when autoMounts=true, with the issue's open question about treating TMP the same way resolved and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.