From cef9270527ba9f56ba4c0fb91a0be5be95095b0d Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 2 May 2016 09:11:25 -0400 Subject: [PATCH] Switch Dockerized commands to use sh instead of bash. We switched to bash for the conda and that doesn't get sourced in containers - so we should be a bit pragmatic about this and switch back to /bin/sh for containers which is more common than /bin/bash. xref https://github.com/galaxyproject/galaxy/pull/2278 Update galaxy.ini.sample to mention this as suggested by @bgruening in https://github.com/galaxyproject/galaxy/pull/2282#issuecomment-216232788. --- config/galaxy.ini.sample | 9 +++++---- lib/galaxy/jobs/command_factory.py | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/config/galaxy.ini.sample b/config/galaxy.ini.sample index dbc13b0ca32e..d3dad1958070 100644 --- a/config/galaxy.ini.sample +++ b/config/galaxy.ini.sample @@ -307,11 +307,12 @@ paste.app_factory = galaxy.web.buildapp:app_factory #check_job_script_integrity_sleep = .25 -# Set the default shell used by jobs Galaxy-wide. This defaults to -# bash and can be overidden at the destination level for -# heterogenous clusters. conda job resolution requires bash or zsh +# Set the default shell used by non-containerized jobs Galaxy-wide. This +# defaults to bash for all jobs and can be overidden at the destination +# level for heterogenous clusters. conda job resolution requires bash or zsh # so if this is switched to /bin/sh for instance - conda resolution -# should be disabled. +# should be disabled. Containerized jobs always use /bin/sh - so more maximum +# portability tool authors should assume generated commands run in sh. #default_job_shell = /bin/bash # Citation related caching. Tool citations information maybe fetched from diff --git a/lib/galaxy/jobs/command_factory.py b/lib/galaxy/jobs/command_factory.py index d57cd77d199b..62b5384088f6 100644 --- a/lib/galaxy/jobs/command_factory.py +++ b/lib/galaxy/jobs/command_factory.py @@ -58,7 +58,12 @@ def build_command( __handle_dependency_resolution(commands_builder, job_wrapper, remote_command_params) if container or job_wrapper.commands_in_new_shell: - externalized_commands = __externalize_commands(job_wrapper, shell, commands_builder, remote_command_params) + if container: + # Many Docker containers do not have /bin/bash. + external_command_shell = "/bin/sh" + else: + external_command_shell = shell + externalized_commands = __externalize_commands(job_wrapper, external_command_shell, commands_builder, remote_command_params) if container: # Stop now and build command before handling metadata and copying # working directory files back. These should always happen outside