question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot choose between the following variants of com.pinterest:ktlint:0.41.0

See original GitHub issue

I have upgraded ktlint from 0.40.0 to 0.41.0. However, I am getting below error when I run ./gradlew ktlintCheck. There is no change in my config between two versions. How do I fix this? Thank you.

* What went wrong:
Execution failed for task ':loadKtlintReporters'.
> Could not resolve all files for configuration ':ktlint'.
   > Could not resolve com.pinterest:ktlint:0.41.0.
     Required by:
         project :
      > Cannot choose between the following variants of com.pinterest:ktlint:0.41.0:
          - runtimeElements
          - shadowRuntimeElements
        All of them match the consumer attributes:
          - Variant 'runtimeElements' capability com.pinterest:ktlint:0.41.0:
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it
                  - Provides org.gradle.jvm.version '8' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
                  - Provides org.jetbrains.kotlin.localToProject 'public' but the consumer didn't ask for it
                  - Provides org.jetbrains.kotlin.platform.type 'jvm' but the consumer didn't ask for it
          - Variant 'shadowRuntimeElements' capability com.pinterest:ktlint:0.41.0:
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.dependency.bundling 'shadowed' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it

Sorry, since it is a private repo, I am posting the relative parts here.

ktlint configuration

ktlint {
   android = true
   enableExperimentalRules = true
   ignoreFailures = false
   version = "0.41.0"
   filter {
       exclude("**/generated/**", "**/build/**")
   }
   reporters {
       reporter "html"
   }
}

.editorconfig

# EditorConfig: http://editorconfig.org
root=true

[*]
insert_final_newline=true
disabled_rules=import-ordering,chain-wrapping,experimental:spacing-between-declarations-with-comments

[*.{kt,kts}]
max_line_length=120

[**/test/**.kt]
max_line_length=off

Working env

  • ktlint version: 0.41.0
  • ktlint-gradle plugin version: 10.0.0
  • Gradle: 6.8.3
  • Android Studio: 4.1.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
BraisGabincommented, Apr 7, 2021

If someone want the workaroud using Kotlin DSL:

configurations.named("ktlint").configure {
    resolutionStrategy {
        dependencySubstitution {
            substitute(module("com.pinterest:ktlint")).with(variant(module("com.pinterest:ktlint:0.41.0")) {
                attributes {
                    attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling::class, Bundling.EXTERNAL))
                }
            })
        }
    }
}
2reactions
Tapchicomacommented, Apr 6, 2021

Will be included into #459 PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot choose between the following variants of com ... - GitHub
I have upgraded ktlint from 0.40.0 to 0.41.0. However, I am getting error when I execute ./gradlew ktlintCheck. How do I fix this?...
Read more >
android - Problems running ktlint from module - Stack Overflow
Required by: project :app Cannot choose between the following variants of project :custom_ktlint_rules: - debugRuntimeElements - ...
Read more >
Ktlint
ktlint aims to capture the official Kotlin coding conventions and Android Kotlin Style Guide. ... ktlint offers a standard and an experimental rule...
Read more >
com.pinterest.ktlint : ktlint-reporter-html : 0.37.0 - Maven Central
ktlint -reporter-html - An anti-bikeshedding Kotlin linter with built-in formatter.
Read more >
jeremymailen / ktlint Download - JitPack
ktlint recognizes the following .editorconfig properties (provided they are specified under [*. ... Supports only single blank lines between imports.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found