Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KFMT_idea_plugin crashes with Intellij 2024.3 #523

Closed
olivierbeltrandocintoo opened this issue Dec 2, 2024 · 21 comments
Closed

KFMT_idea_plugin crashes with Intellij 2024.3 #523

olivierbeltrandocintoo opened this issue Dec 2, 2024 · 21 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@olivierbeltrandocintoo
Copy link

olivierbeltrandocintoo commented Dec 2, 2024

Hello, the ktfmt_idea_plugin crashes with version 2024.3 of Intellij.

Steps to reproduce:

  • Install the plugin
  • format code with ctrl + alt + l

System:

  • Windows 11

Here is the stacktrace:

java.lang.ExceptionInInitializerError
	at com.facebook.ktfmt.format.Formatter.sortedAndDistinctImports(Formatter.kt:157)
	at com.facebook.ktfmt.format.Formatter.format(Formatter.kt:103)
	at com.facebook.ktfmt.intellij.KtfmtFormattingService$KtfmtFormattingTask.run(KtfmtFormattingService.kt:62)
	at com.intellij.formatting.service.AsyncDocumentFormattingService$FormattingRequestImpl.runTask(AsyncDocumentFormattingService.java:261)
	at com.intellij.formatting.service.AsyncDocumentFormattingService.runAsyncFormat(AsyncDocumentFormattingService.java:106)
	at com.intellij.formatting.service.AsyncDocumentFormattingService$FormattingProgressTask.run(AsyncDocumentFormattingService.java:380)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:491)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:133)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$7(CoreProgressManager.java:542)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:249)
	at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:98)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:223)
	at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.use(trace.kt:45)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:222)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$14(CoreProgressManager.java:674)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:749)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:705)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:673)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:203)
	at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:98)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$5(ProgressRunner.java:249)
	at com.intellij.openapi.progress.impl.ProgressRunner$ProgressRunnable.run(ProgressRunner.java:502)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$18(ProgressRunner.java:467)
	at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:101)
	at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:101)
	at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:107)
	at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:101)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$19(ProgressRunner.java:463)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.UnsupportedOperationException
	at java.base/sun.nio.fs.WindowsFileSystem.close(WindowsFileSystem.java:91)
	at com.intellij.platform.core.nio.fs.DelegatingFileSystem.close(DelegatingFileSystem.java:40)
	at org.jetbrains.kotlin.com.intellij.ide.plugins.DescriptorLoadingContext.close(DescriptorLoadingContext.java:49)
	at org.jetbrains.kotlin.com.intellij.ide.plugins.PluginManagerCore.registerExtensionPointAndExtensions(PluginManagerCore.java:1327)
	at org.jetbrains.kotlin.com.intellij.core.CoreApplicationEnvironment.registerExtensionPointAndExtensions(CoreApplicationEnvironment.java:287)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerApplicationExtensionPointsAndExtensionsFrom(KotlinCoreEnvironment.kt:625)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createApplicationEnvironment(KotlinCoreEnvironment.kt:595)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironment(KotlinCoreEnvironment.kt:505)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironmentForProduction(KotlinCoreEnvironment.kt:492)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:440)
	at com.facebook.ktfmt.format.Parser.<clinit>(Parser.kt:57)
	... 36 more

image

Thanks in advance :)
Cheers,
Olivier

@WeisSebastian
Copy link

Having the same issue with the same stack traces. Can confirm it started happening after upgrading to IntelliJ 2024.3

@jessestricker
Copy link

This also happens in the latest IntelliJ IDEA 2024.3.1 patch release.

@RealityTest
Copy link

Happens to me aswell on 2024.3.1.1

@levifernandesfs
Copy link

Did you resolve this issue?

@hick209 hick209 added the bug Something isn't working label Jan 10, 2025
@hick209
Copy link
Contributor

hick209 commented Jan 10, 2025

What version of the plugin are you using?
Do you have K2 mode enabled in your IDE?
What is your IDE version?

I have not yet been able to reproduce it with either K1 nor K2 modes
IDE version: IC-243.21565.193
ktfmt plugin version: 1.2.0.53

@hick209
Copy link
Contributor

hick209 commented Jan 10, 2025

Oh, I'm on macOS, could that be it? 🤔
If so I might need help on this one since I don't have a Windows machine

@olivierbeltrandocintoo
Copy link
Author

Version of Intellij:

  • IntelliJ IDEA 2024.3.1.1 (Community Edition)
  • Build #IC-243.22562.218, built on December 18, 2024

image

Version of the ktfmt plugin: 1.2.0.53
image

K2 is enabled
image

Thanks a lot in advance for the help :)

@JavierSegoviaCordoba
Copy link
Contributor

Oh, I'm on macOS, could that be it? 🤔

If so I might need help on this one since I don't have a Windows machine

It only happens on Windows.

@janchristian-haddorp
Copy link

Just as info if not clear so far... Setting of K2 mode flag doesn't matter - same issue independent of K2 mode setting.

In our team we are using IntelliJ IDEA Ultimate (2024.3.1.1 / #IU-243.22562.218), all on Windows. Happy to support.

@c1rcle
Copy link

c1rcle commented Jan 15, 2025

ktfmt is targeting Kotlin 1.8.22 whose compiler depends on an ancient IntelliJ platform SDK (203.8084.24). I bumped Kotlin to the latest stable version (2.1.0), built the plugin locally and it seems to work just fine. Not sure whether this is an acceptable solution though.

@hick209
Copy link
Contributor

hick209 commented Jan 15, 2025

@c1rcle that's a great finding! How about 2.0.0 would that work? If so I can make another release with that

@c1rcle
Copy link

c1rcle commented Jan 15, 2025

@hick209 Just ran a quick test and yeah, 2.0.0 works too. Verified on IntelliJ IDEA 2024.3.1.1 (243.22562.218).

@hick209
Copy link
Contributor

hick209 commented Jan 15, 2025

Awesome! Bumping it to 2.0.0 then. Let's hope this fixes things

@olivierbeltrandocintoo
Copy link
Author

Then probably consider using 2.0.X (like 2.0.10 or 2.0.20) that contain bugfixes found in 2.0.0 :)
But maybe this is not relevant. Thanks for everything

facebook-github-bot pushed a commit that referenced this issue Jan 15, 2025
Summary:
This seems to fix some issues that we are seeing on Windows machines.

#523

Reviewed By: cortinico

Differential Revision: D68211603

fbshipit-source-id: 3a12c05a6a7e0b827d353df2acc2d5b2380a4d14
@hick209
Copy link
Contributor

hick209 commented Jan 15, 2025

Released 0.54 that hopefully will fix this issue.

For now we're on 2.0.0, but we are discussing pushing to the latest 2.0.x, which would be 2.0.21, as that would be quite similar to 2.0.0 except for some code fixes.

Right now we only bumped to 2.0.0 to try to make sure ktfmt is available for a broad range of use cases.

@olivierbeltrandocintoo
Copy link
Author

Excellent news, I have been hitting the refresh button this morning a lot of times in Intellij, but no luck yet, the version 0.54 of the plugin does not appear in the marketplace (yet)

Image
https://plugins.jetbrains.com/plugin/14912-ktfmt/versions

How long does it take to normally show up ?

@ezamelczyk
Copy link

Normally I'd just install the plugin manually from the releases page but I see that you do not distribute installable plugin package there. Is there a reason for that?

@hick209
Copy link
Contributor

hick209 commented Jan 16, 2025

@olivierbeltrandocintoo, it's probably stuck in JB review process, which can take a while. According to Google up to 4 days, but usually it's a couple of days from what I've seem with ktfmt

Image

@ezamelczyk, that's actually a good idea for now, it's just extra work. Do you happen to know or have pointers on how we could automate that? If we do this, it would be guaranteed to be there all the time

@olivierbeltrandocintoo
Copy link
Author

It's there !
Image

Also available inside Intellij from the marketplace !

And it works 🍾 🤩

Really awesome !! Thanks a lot to all 😄

@hick209
Copy link
Contributor

hick209 commented Jan 16, 2025

That's awesome!
Thanks everyone for reporting, for your help towards finding a fix and for the patience while we get it out there

@ezamelczyk
Copy link

@hick209 sorry I've never built an IntellijIDEA plugin so I'm not sure how to do that but isn't the package you're uploading to the jetbrains marketplace basically the same thing? It should be just a zip file afaik.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

10 participants