You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
coursier: additional_dependencies with non-default channel #2986
changed the title [-]coursier: additional_dependencies with custom channel[/-][+]coursier: additional_dependencies with non-default channel[/+]on Sep 3, 2023
However, this will result in an error when executed.
❯ pre-commit run --all-files -v
[INFO] Installing environment for https://github.com/junghoon-vans/pre-coursier.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/opt/homebrew/bin/cs', 'install', '--dir', '/Users/jeonghun/.cache/pre-commit/repodauna3u9/coursier-default', '--channel', 'central', 'com.puppycrawl.tools:checkstyle:10.8.0')
return code: 1
stdout: (none)
stderr:
Downloading https://repo1.maven.org/maven2/io/get-coursier/apps/maven-metadata.xml
Downloaded https://repo1.maven.org/maven2/io/get-coursier/apps/maven-metadata.xml
Downloading https://repo1.maven.org/maven2/io/get-coursier/apps/1.0.40/apps-1.0.40.pom
Downloaded https://repo1.maven.org/maven2/io/get-coursier/apps/1.0.40/apps-1.0.40.pom
Downloading https://repo1.maven.org/maven2/io/get-coursier/apps/1.0.40/apps-1.0.40.jar
Downloaded https://repo1.maven.org/maven2/io/get-coursier/apps/1.0.40/apps-1.0.40.jar
Cannot find app com.puppycrawl.tools in channels /Users/jeonghun/.cache/pre-commit/repodauna3u9/central, io.get-coursier:apps
Check the log at /Users/jeonghun/.cache/pre-commit/pre-commit.log
I was wondering if I should pass --default-channel=false, so I put it in, but I still get the error.
❯ pre-commit run --all-files -v
[INFO] Initializing environment for https://github.com/junghoon-vans/pre-coursier:--default-channels=false --channel central com.puppycrawl.tools:checkstyle:10.8.0.
[INFO] Installing environment for https://github.com/junghoon-vans/pre-coursier.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/opt/homebrew/bin/cs', 'fetch', '--default-channels=false --channel central com.puppycrawl.tools:checkstyle:10.8.0')
return code: 1
stdout: (none)
stderr:
Argument --default-channels: Unrecognized flag value: false --channel central com.puppycrawl.tools:checkstyle:10.8.0
Check the log at /Users/jeonghun/.cache/pre-commit/pre-commit.log
yeah I'm not super familiar with coursier myself -- if you can show me commands to install checkstyle using coursier outside of pre-commit I can tell you what the pre-commit config should look like
sorry took me a while to get back to this -- I think given that it needs additional metadata since it's not traditionally packaged via coursier then it's not possible with additional_dependencies unfortunately
Activity
[-]coursier: additional_dependencies with custom channel[/-][+]coursier: additional_dependencies with non-default channel[/+]asottile commentedon Sep 3, 2023
you can already put
--channel, ...in additional_dependencies to accomplish what you wantjunghoon-vans commentedon Sep 3, 2023
@asottile Thank you for your advice.
Am I correct that you are referring to running something like this?
However, this will result in an error when executed.
I was wondering if I should pass
--default-channel=false, so I put it in, but I still get the error.asottile commentedon Sep 3, 2023
yeah I'm not super familiar with coursier myself -- if you can show me commands to install checkstyle using coursier outside of pre-commit I can tell you what the pre-commit config should look like
junghoon-vans commentedon Sep 4, 2023
@asottile sure this is two way to install checkstyle using coursier.
General
Since checkstyle is an application that is not in coursier's default channel, it must be explicitly specified.
Application descriptors
{ "mainClass": "com.puppycrawl.tools.checkstyle.Main", "repositories": [ "central" ], "dependencies": [ "com.puppycrawl.tools:checkstyle:latest.release" ] }Once you've registered your
checkstyle.jsonin your.pre-commit-channelas above, you can use it as shown below.Since it's registered to a custom channel, you don't need to explicitly show the library.
asottile commentedon Sep 10, 2023
sorry took me a while to get back to this -- I think given that it needs additional metadata since it's not traditionally packaged via coursier then it's not possible with
additional_dependenciesunfortunatelyjunghoon-vans commentedon Sep 11, 2023
@asottile
So why not specify the
repositoriesspecified inside the application descriptors as the repositories foradditional_dependencies?Currently, pre-commit seems to use the channel in the application descriptors with disable default channel.
https://github.com/pre-commit/pre-commit/blob/5f4b82899929ffdaf94f81ed01dec4e9a1d98636/pre_commit/languages/coursier.py#L51C17-L51C25
so it makes more sense that the channels in additional dependencies follow those defined in the application descriptors.
Example
.pre-commit-channel/checkstyle.json
{ "mainClass": "com.puppycrawl.tools.checkstyle.Main", "repositories": [ "central", "https://some.custom.maven/repository" ], "dependencies": [ "com.puppycrawl.tools:checkstyle:latest.release" ] }Define two repositories.
.pre-commit-config.yaml
Additional dependencies are pulled from the repositories that defined in
.pre-commit-channel/checkstyle.json