diff --git a/snakemake/deployment/conda.py b/snakemake/deployment/conda.py index 473ac2b23..d409e6952 100644 --- a/snakemake/deployment/conda.py +++ b/snakemake/deployment/conda.py @@ -624,19 +624,16 @@ def _check(self): try: version = shell.check_output( self._get_cmd("conda --version"), - stderr=subprocess.STDOUT, + stderr=subprocess.PIPE, universal_newlines=True, ) - if self.container_img: - version = "\n".join( - filter( - lambda line: not line.startswith("WARNING:") - and not line.startswith("ERROR:"), - version.splitlines(), - ) + version_matches = re.findall("\d+.\d+.\d+", version) + if len(version_matches) != 1: + raise WorkflowError( + f"Unable to determine conda version. 'conda --version' returned {version}" ) - - version = version.split()[1] + else: + version = version_matches[0] if StrictVersion(version) < StrictVersion("4.2"): raise CreateCondaEnvironmentException( "Conda must be version 4.2 or later, found version {}.".format( @@ -645,7 +642,7 @@ def _check(self): ) except subprocess.CalledProcessError as e: raise CreateCondaEnvironmentException( - "Unable to check conda version:\n" + e.output.decode() + "Unable to check conda version:\n" + e.stderr.decode() ) def bin_path(self):