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 use ktfmt with Kotlin 1.6.0

See original GitHub issue

Hi there!

Now that Kotlin 1.6.0 is out, I just attempted to upgrade one of our projects and hit a roadblock with ktfmt (used via the Spotless Gradle Plugin, but configured to use the latest ktfmt 0.29 version):

> Task spotlessKotlin FAILED
Step 'ktfmt' found problem in '/path/to/some/file.kt':
Unsupported runtime Kotlin version: 1.6.0
java.lang.RuntimeException: Unsupported runtime Kotlin version: 1.6.0
        at com.facebook.ktfmt.FormatterKt.createAstVisitor(Formatter.kt:162)
        at com.facebook.ktfmt.FormatterKt.prettyPrint(Formatter.kt:136)
        at com.facebook.ktfmt.FormatterKt.format(Formatter.kt:124)
        at com.facebook.ktfmt.FormatterKt.format(Formatter.kt:105)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at com.diffplug.spotless.kotlin.KtfmtStep$State.lambda$createFormat$0(KtfmtStep.java:128)
        at com.diffplug.spotless.FormatterFunc.apply(FormatterFunc.java:32)
        at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:78)
        at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:76)
        at com.diffplug.spotless.Formatter.compute(Formatter.java:230)
        at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:201)
        at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:188)
        at com.diffplug.gradle.spotless.SpotlessTaskImpl.processInputFile(SpotlessTaskImpl.java:88)
        at com.diffplug.gradle.spotless.SpotlessTaskImpl.performAction(SpotlessTaskImpl.java:74)

I saw that 37525533aa8c32d1a501bc7f617b05179311752d somehow fixes this issue. So my question is, do you intend to publish a new release of ktfmt with this commit (even if new language features are not handled yet) ? This would unblock projects migrating to Kotlin 1.6. Or at least, publishing a snapshot version would be great as well.

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cgrushkocommented, Nov 17, 2021

0.3 should be available in Maven soon.

1reaction
cgrushkocommented, Nov 17, 2021

ktfmt on main doesn’t crash like this, but possibly doesn’t support some language constructs. Lemme push a new version with it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

facebook/ktfmt: A program that reformats Kotlin ... - GitHub
A program that reformats Kotlin source code to comply with the common community standard for Kotlin code conventions. - GitHub - facebook/ktfmt: A...
Read more >
I m trying to get Gradle JVM toolchain working for a multi m
I've tried to specify the kotlin / java toolchain blocks above per project, in allProjects or subProjects but those result in compile errors...
Read more >
Android - Hilt issues when upgrading to Kotlin 1.6.0
Solution. The issue was how I incorrectly handled the kapt errors after upgrading Kotlin. I reverted all of my annotationProcessor(.
Read more >
ktfmt - IntelliJ IDEs Plugin - JetBrains Marketplace
ktfmt is a program that reformats Kotlin source code to comply with the common community standard for Kotlin code conventions. Plugin Site. Issue...
Read more >
ktfmt - the Kotlin code formatter
Usage. IntelliJ / Android Studio; Gradle; Maven; Command line. A ktfmt plugin that augments the Reformat Code action ...
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