From 7846572349bbe5ecab38521779b307a066784a23 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Thu, 17 Mar 2022 15:31:01 +0100 Subject: [PATCH] coursier: Add support for both `cs` and `coursier` executable names On some systems, the executable might be named `coursier` instead of `cs`. For example, this is the case on Arch Linux when using the AUR package, or when following the official instructions when installing the JAR-based launcher: https://get-coursier.io/docs/cli-installation#jar-based-launcher --- pre_commit/languages/coursier.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pre_commit/languages/coursier.py b/pre_commit/languages/coursier.py index e47f9c873..8fde355c9 100644 --- a/pre_commit/languages/coursier.py +++ b/pre_commit/languages/coursier.py @@ -27,6 +27,14 @@ def install_environment( helpers.assert_version_default('coursier', version) helpers.assert_no_additional_deps('coursier', additional_dependencies) + # Support both possible executable names (either "cs" or "coursier") + executable = next(filter(helpers.exe_exists, ('cs', 'coursier')), None) + if executable is None: + raise AssertionError( + 'pre-commit requires system-installed "cs" or "coursier" ' + 'executables in the application search path', + ) + envdir = prefix.path(helpers.environment_dir(ENVIRONMENT_DIR, version)) channel = prefix.path('.pre-commit-channel') with clean_path_on_failure(envdir): @@ -36,7 +44,7 @@ def install_environment( helpers.run_setup_cmd( prefix, ( - 'cs', + executable, 'install', '--default-channels=false', f'--channel={channel}',