| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
you can already put --channel, ... in additional_dependencies to accomplish what you want
@asottile Thank you for your advice.
Am I correct that you are referring to running something like this?
repos:
- repo: https://github.com/junghoon-vans/pre-coursier
rev: v0.2.0
hooks:
- id: checkstyle
args: [".", "-c", "./sun_checks.xml"]
additional_dependencies: ["--channel", "central", "com.puppycrawl.tools:checkstyle:10.8.0"]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
@asottile sure this is two way to install checkstyle using coursier.
cs install com.puppycrawl.tools:checkstyle:latest.releaseSince checkstyle is an application that is not in coursier's default channel, it must be explicitly specified.
{
"mainClass": "com.puppycrawl.tools.checkstyle.Main",
"repositories": [
"central"
],
"dependencies": [
"com.puppycrawl.tools:checkstyle:latest.release"
]
}Once you've registered your checkstyle.json in your .pre-commit-channel as above, you can use it as shown below.
cs install --default-channels=false --channel=.pre-commit-channel checkstyle:latest.releaseSince it's registered to a custom channel, you don't need to explicitly show the library.
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
@asottile
So why not specify the repositories specified inside the application descriptors as the repositories for additional_dependencies?
Currently, pre-commit seems to use the channel in the application descriptors with disable default channel.
so it makes more sense that the channels in additional dependencies follow those defined in the application descriptors.
.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
repos:
- repo: https://github.com/junghoon-vans/pre-coursier
rev: v0.2.0
hooks:
- id: checkstyle
args: [".", "-c", "./sun_checks.xml"]
additional_dependencies: ["com.puppycrawl.tools:checkstyle:10.8.0"] # from central or https://some.custom.maven/repositoryAdditional dependencies are pulled from the repositories that defined in .pre-commit-channel/checkstyle.json
| Back | FazBrowse Home | New Git URL |
search you tried in the issue tracker
#2702
describe your actual problem
Description
Currently, coursier's additional_dependencies only supports the default channel.
This means it can't pull dependencies from repositories like central.
AS-IS
Solution
How about changing central to the default repository for more dependencies?
In fact, coursier's default repository also fetches files from central.
TO-BE
pre-commit --version
pre-commit:3.4.0