Skip to content

Make Bash path configurable - #5696

Closed
pditommaso wants to merge 3 commits into
masterfrom
make-bash-path-configurable
Closed

pditommaso wants to merge 3 commits into
masterfrom
make-bash-path-configurable

Conversation

@pditommaso

Copy link
Copy Markdown
Member

This PR allows the customisation of Bash interpreter used by Nextflow go a user provided path defined via nextflow config file or an environment variable (to be done).

Signed-off-by: Paolo Di Tommaso <[email protected]>
@netlify

netlify Bot commented Jan 22, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit e389489
🔍 Latest deploy log https://app.netlify.com/sites/nextflow-docs-staging/deploys/67d55551acbbd000089d709e


@Memoized
static String bash() {
session().config.navigate('nextflow.defaults.bash') ?: '/bin/bash'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This config scope was renamed to workflow, I would just call it workflow.bash

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss about this. I think we need to nextflow wide setting (more tied to runtime than workflow concept)

Comment on lines -87 to +88
BASH = Collections.unmodifiableList( level > 0 ? ['/bin/bash','-uex'] : ['/bin/bash','-ue'] )

BASH = Collections.unmodifiableList( level > 0 ? [NF.bash(), '-uex'] : [NF.bash(), '-ue'] )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This use of NF.bash() makes me think that the user bash setting can only be the bash path itself and can't include extra arguments like env -S bash or bash -o pipefail. Will that be acceptable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal should be to specify a custom Bash path not to alter the shell option. That's possible in some extent via process.shell

}
BASH = Collections.unmodifiableList( level > 0 ? ['/bin/bash','-uex'] : ['/bin/bash','-ue'] )

BASH = Collections.unmodifiableList( level > 0 ? [NF.bash(), '-uex'] : [NF.bash(), '-ue'] )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that BASH is used for both running the task on the host as well as within the container. This means NF.bash should be something that is acceptable in both situations (OR: one has to change the profile and NF.bash at the same time if one needs to use different interpreters depending on whether the task runs on a host or on a container). I also understand that /bin/bash is the only official entry point to run docker containers.

Maybe for some context, here is a test script that I am using to check whether the Nextflow package is running as expected on NixOS. I'm linking this here to show what my goal is/was with #5684. (The test is easy to understand without knowledge of Nix.). 5684 would allow me to pass this test.

I think even today, I could use an unpatched Nextflow on NixOS if I "simply" adapt process.shell everywhere. Tracing might not work. I'd like to improve on that situation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means NF.bash should be something that is acceptable in both situations

Yes, that's correct.

I think even today, I could use an unpatched Nextflow on NixOS if I "simply" adapt process.shell everywhere. Tracing might not work. I'd like to improve on that situation.

my understanding is that in NixOS the Bash interpreter is located at /usr/bin/bash so this PR should solve the problem with a minimal setting.

Is it not the case?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NixOS has bash at /run/current-system/sw/bin/bash but the correct way to invoke it is /usr/bin/env -S bash.

But: The docker images doesn't have it there. They have it (officially) at /bin/bash. My whole point is that I want the system to not use the same (path to) bash in both cases (docker execution vs host execution). Let me write a another comment to explain the situation below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. What's preventing creating a symlink to "normalise" it?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Nix package cannot create arbitrary files on the file system. Actually, older definitions of the Nextflow package used a wrapper to make nextflow believe that /bin/bash exists. However, using this wrapper comes with other drawbacks.

Signed-off-by: Paolo Di Tommaso <[email protected]>
@rollf

rollf commented Jan 22, 2025

Copy link
Copy Markdown

Thank you for addressing my issues @pditommaso.

NixOS currently patches Nextflow so that it can run there even though /bin/bash is not available. This works great unless one wants to enable tracing. Instead of improving the patch, I thought it might be nice to solve the issue upstream. Hence my motivation for #5432. I closed that PR in favor of #5684 (because the latter is more clean and I also updated my initial implementation since #4209 got merged in the meantime).

Now, #5684 got also closed and my approach will not be merged (reasoning is mentioned here) in favor of this PR here. I believe this PR here does not improve the situation for NixOS (see my reasoning here and here).

Thus, I see two options now

  • Either: I'm wrong and this PR here does indeed improve the situation for NixOS in all 4 scenarios (docker on/off x tracing on/off) with minimal additional patching/configuration upfront but without having to touch the actual pipeline and without having to change process.shell when enabling/disabling docker/tracing.
  • Or: This PR here does not help and I thus suggest to not merge if it was only motivated by supporting NixOS (since Nextflow doesn't need it). The Nix package definition for Nextflow will then continue to patch vanilla Nextflow; the patch will of course be improved to allow the tracing scenario (i.e. simply derive a patch from Use /usr/bin/env -S bash instead of /bin/bash on the host system #5684 and apply it).

I can test option 1) but would need advice how you envision this to be used. However, we might also directly agree on option 2).

(For option 2, it would make my life easier if this PR here does not get merged. But this is of course entirely up to others to decide)

@pditommaso
pditommaso marked this pull request as draft January 23, 2025 11:59
@pditommaso
pditommaso force-pushed the master branch 2 times, most recently from 5a93547 to 27345a6 Compare February 10, 2025 21:46
@rollf

rollf commented Feb 27, 2025

Copy link
Copy Markdown

@pditommaso could you have a look at my comment above and give some feedback? Thanks.

@bentsherman

Copy link
Copy Markdown
Member

Closing due to age. It seems we weren't able to decide whether this change was worthwhile

@bentsherman
bentsherman deleted the make-bash-path-configurable branch February 26, 2026 22:08
@rollf

rollf commented Feb 27, 2026

Copy link
Copy Markdown

@bentsherman I think this is fine for the NixOS community. I mentioned above that IMHO this PR here would have worsened the situation for NixOS. Besides, a Nix-specific solution has been recently discussed/imlemented/merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: Make "/bin/bash" configurable

3 participants