Skip to content

Commit 678ef6b

Browse files
committed
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
1 parent da55e97 commit 678ef6b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pre_commit/languages/coursier.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pre_commit.envcontext import Var
1111
from pre_commit.hook import Hook
1212
from pre_commit.languages import helpers
13+
from pre_commit.parse_shebang import find_executable
1314
from pre_commit.prefix import Prefix
1415
from pre_commit.util import clean_path_on_failure
1516

@@ -27,6 +28,14 @@ def install_environment(
2728
helpers.assert_version_default('coursier', version)
2829
helpers.assert_no_additional_deps('coursier', additional_dependencies)
2930

31+
# Support both possible executable names (either "cs" or "coursier")
32+
executable = find_executable('cs') or find_executable('coursier')
33+
if executable is None:
34+
raise AssertionError(
35+
'pre-commit requires system-installed "cs" or "coursier" '
36+
'executables in the application search path',
37+
)
38+
3039
envdir = prefix.path(helpers.environment_dir(ENVIRONMENT_DIR, version))
3140
channel = prefix.path('.pre-commit-channel')
3241
with clean_path_on_failure(envdir):
@@ -36,7 +45,7 @@ def install_environment(
3645
helpers.run_setup_cmd(
3746
prefix,
3847
(
39-
'cs',
48+
executable,
4049
'install',
4150
'--default-channels=false',
4251
f'--channel={channel}',

0 commit comments

Comments
 (0)