From d917d3d4b67f0801d638c754d40394e857df3af0 Mon Sep 17 00:00:00 2001 From: Matt Rixman Date: Tue, 26 Jul 2022 22:39:58 -0600 Subject: [PATCH] fix - resolve bash by absolute path --- airflow/operators/bash.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/airflow/operators/bash.py b/airflow/operators/bash.py index b470f4d85f442..15e0a6cafae71 100644 --- a/airflow/operators/bash.py +++ b/airflow/operators/bash.py @@ -16,6 +16,7 @@ # specific language governing permissions and limitations # under the License. import os +import shutil from typing import Dict, Optional, Sequence from airflow.compat.functools import cached_property @@ -174,6 +175,7 @@ def get_env(self, context): return env def execute(self, context: Context): + bash_path = shutil.which("bash") or "bash" if self.cwd is not None: if not os.path.exists(self.cwd): raise AirflowException(f"Can not find the cwd: {self.cwd}") @@ -181,7 +183,7 @@ def execute(self, context: Context): raise AirflowException(f"The cwd {self.cwd} must be a directory") env = self.get_env(context) result = self.subprocess_hook.run_command( - command=['bash', '-c', self.bash_command], + command=[bash_path, '-c', self.bash_command], env=env, output_encoding=self.output_encoding, cwd=self.cwd,