Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "/usr/bin/env bash" instead of "/bin/bash" #1598

Closed
unode opened this issue May 7, 2020 · 8 comments · Fixed by #1614
Closed

Use "/usr/bin/env bash" instead of "/bin/bash" #1598

unode opened this issue May 7, 2020 · 8 comments · Fixed by #1614

Comments

@unode
Copy link

unode commented May 7, 2020

Bug report

% nextflow run hello
N E X T F L O W  ~  version 20.04.1
Launching `nextflow-io/hello` [modest_lamarr] - revision: 1d43afc0ec [master]
WARN: The use of `echo` method is deprecated
executor >  local (4)
[a8/932405] process > sayHello (2) [100%] 1 of 1, failed: 1
WARN: Killing pending tasks (3)
Error executing process > 'sayHello (4)'

Caused by:
  Cannot run program "/bin/bash" (in directory "/tmp/work/7d/a941cf3b6cae277c641136cd0aee2d"): error=2, No such file or directory

Command executed:

  echo 'Hola world!'

Command exit status:
  -

Command output:
  (empty)

Work dir:
  /tmp/work/7d/a941cf3b6cae277c641136cd0aee2d

Tip: you can replicate the issue by changing to the process work dir and entering the command `bash .command.run`

The Tip actually runs as expected

% cd /tmp/work/fa/adc77db68ead7e6681d4e24f3df388
% bash .command.sh 
Bonjour world!

Expected behavior and actual behavior

On some systems /bin/bash doesn't exist. This causes failures at many levels since /bin/bash is hardcoded in many locations in nextflow's codebase, including the shebang of the nextflow-X.X.X.all release files.

The compatible alternative is to use /usr/bin/env bash or, if involving shebangs and multiple arguments, #!/usr/bin/env -S bash -ue. See also coreutils - env -S.

Environment

  • Nextflow version: 20.04.1
  • Java version: openjdk 11.0.6-internal 2020-01-14
  • Operating system: Linux - NixOS 20.03
  • Bash version: (use the command $SHELL --version)
% $SHELL --version
zsh 5.7.1 (x86_64-pc-linux-gnu)
% bash --version
GNU bash, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)
@edmundmiller
Copy link
Contributor

Same issue on Nixos 20.03 also.

#!/usr/bin/env bash

Works for me.

edmundmiller added a commit to edmundmiller/nextflow that referenced this issue May 29, 2020
pditommaso pushed a commit that referenced this issue Aug 1, 2020
@unode
Copy link
Author

unode commented Aug 1, 2020

Doing a quick search on /bin/bash shows that there are still other paths that might need to be corrected.

Pull request #1614 fixed only the nextflow launcher.

@pditommaso
Copy link
Member

Well, the issue was automatically closed when merging the associated PR. Said that there's no plan to change the current usage of /bin/bash. This may have an impact on too many existing applications that's diffcult to assess.

Also, the proposed alternative suffers from the same issue. Try for example docker run busybox /usr/bin/env.

/bin/bash should be considered a requirement.

@unode
Copy link
Author

unode commented Aug 3, 2020

Well, docker run busybox /bin/bash doesn't work either so that's a bit of an unfair comparison, but I understand the difficulty to assess other applications.

Would it be too risky to simply drop the full path whenever called from a script? i.e. /bin/bash args becoming bash args?
This is equivalent to using /usr/bin/env from shebangs.

I'm happy to provide a PR with the necessary changes to any existing reference to /bin/bash.

@pditommaso
Copy link
Member

Not so unfair because busybox is used as base image for biocontainers to which /bin/bash is added and for NF support for containers is a paramount feature.

The only solution that I can see is to make the shell path configurable via config setting (env var or config file) which defaults to /bin/bash and the user can change as needed.

@edmundmiller
Copy link
Contributor

Sorry this got closed automagically.

I agree that support for containers is a major feature and shouldn't be broken, and even if we convinced the biocontainers group to change, there are still tons of previous images that would still have /bin/bash.

I think making the shell path configurable is only only option also because of that. It's probably not a priority though because /bin/bash works on the majority of systems.

@edmundmiller
Copy link
Contributor

Just came back to this as I was about to try to package up nextflow with nix. However, I just did ln -s /run/current-system/sw/bin/bash /bin/bash for any lost souls who find this.

@IllustratedMan-code
Copy link

Super quick flake for running under nixos:

{
    inputs = {};
    outputs = {self, nixpkgs, ...}:
    let
        system = "x86_64-linux";
        pkgs = import nixpkgs{inherit system;};
    in
    {
        devShells.${system}.default = with pkgs; (pkgs.buildFHSUserEnv {
            name = "nextflow";
            targetPkgs = pkgs: [pkgs.openjdk];
        }).env;
    };

}

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 a pull request may close this issue.

4 participants