palantir-java-format icon indicating copy to clipboard operation
palantir-java-format copied to clipboard

IDEA IntelliJ plugin silently fails

Open RockyMM opened this issue 1 year ago • 11 comments

It seems that palantir-java-format is silently failing in my installation of IDEA IntelliJ.

I would intentionally mess up the formatting of a source file, and press Cmd-Option-L. I would observe in the task area of IntelliJ that "Running palantir-java-format", but I would observe no change in the format of the source file.

Is there some log I could look at to check what's wrong?

RockyMM avatar Oct 01 '24 09:10 RockyMM

Same problem for here on macOS with IntelliJ IDEA 2024.3 (Ultimate Edition).

dintz avatar Nov 21 '24 09:11 dintz

I have the same issue. Latest plugin version and IntelliJ 2024.1.2.

jordanms avatar Jan 09 '25 10:01 jordanms

Same issue here ...

This is the stacktrace:

java.lang.RuntimeException: Error running formatter command
	at com.palantir.javaformat.bootstrap.BootstrappingFormatterService.getFormatReplacements(BootstrappingFormatterService.java:59)
	at com.palantir.javaformat.intellij.PalantirJavaFormatFormattingService$PalantirJavaFormatFormattingTask.run(PalantirJavaFormatFormattingService.java:94)
	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.io.IOException: Command terminated with exit value 1
Command: /Users/kristof/.sdkman/candidates/java/21.0.5-jbr/bin/java --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -cp /Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/guava-33.0.0-jre.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/j2objc-annotations-2.8.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/jackson-datatype-guava-2.17.2.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/jackson-core-2.17.2.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/failureaccess-1.0.2.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/jackson-databind-2.17.2.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/jackson-annotations-2.17.2.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/palantir-java-format-spi-2.50.0.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/functionaljava-4.8.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/jackson-datatype-jdk8-2.17.2.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/palantir-java-format-2.50.0.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/checker-qual-3.42.0.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/jsr305-3.0.2.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/error_prone_annotations-2.24.1.jar:/Users/kristof/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/palantir-java-format/impl/jackson-module-parameter-names-2.17.2.jar com.palantir.javaformat.java.Main --character-ranges 7259:7412 --output-replacements --palantir -
Stdout:

Stderr:
<stdin>:error: error: invalid length 154, offset + length (7412) is outside the file

	at com.palantir.javaformat.bootstrap.FormatterCommandRunner.runWithStdin(FormatterCommandRunner.java:53)
	at com.palantir.javaformat.bootstrap.BootstrappingFormatterService.getFormatReplacementsInternal(BootstrappingFormatterService.java:93)
	at com.palantir.javaformat.bootstrap.BootstrappingFormatterService.getFormatReplacements(BootstrappingFormatterService.java:57)
	... 34 more

Hope it helps

Kind regards, Kristof

kristof-taveirne avatar Jan 12 '25 19:01 kristof-taveirne

Same problem on IntelliJ IDEA 2024.3.1.1 (Ultimate Edition)

austek avatar Jan 14 '25 10:01 austek

Not sure if same error (I can't find the logs) but with IDEA 2024.3.5 and plugin version 2.61.0 it does not format the open file although I can briefly see Running palantir-java-format.

heruan avatar Mar 25 '25 12:03 heruan

Still no feedback from Palantir on this? I have tried to uninstall/reinstall but still it does not work. I see it runs in the status bar but it does not format any code.

heruan avatar Apr 17 '25 10:04 heruan

I enabled DEBUG logs for com.palantir but the only log I see when I run the formatter is:

2025-04-17 13:20:59,706 [2257811]   FINE - #com.palantir.javaformat.intellij.PalantirJavaFormatFormattingService - Received request to format file=/Users/heruan/Projects/palantir-issue/src/main/java/PalantirExample.java, length=2958 with ranges=[(0,2958)]
2025-04-17 13:21:00,146 [2258251]   FINE - #com.palantir.javaformat.intellij.PalantirJavaFormatFormattingService - Applying 1 replacements with ranges=[[0..2958)]

heruan avatar Apr 17 '25 10:04 heruan

I'm having the same(including those the only two lines in the logs) on Intellij Idea 2025.1.1.1 palantir-java-format plugin 2.67.0

andrej-urvantsev avatar May 23 '25 10:05 andrej-urvantsev

Anybody got past this? I'm now on 2.74.0 and I've just noticed that if I select some code and format, the "Format Code" action it works fine (both menu and shortcut). But, without any code selected, it just doesn't do anything. On the other hand, the "Format File..." menu item always works! What's the deal with "Format Code"? 😕

heruan avatar Sep 11 '25 12:09 heruan

It seems to happen to me when I have "optimize imports" turned on and IDEA's ordering clashes with what Palantir wants to do. Turning off "optimize imports" might help.

Garmelon avatar Sep 11 '25 15:09 Garmelon

It seems to happen to me when I have "optimize imports" turned on and IDEA's ordering clashes with what Palantir wants to do. Turning off "optimize imports" might help.

With or without "optimize imports" does not make a difference, on some files it just does not format regardless of that. Anyways "optimize imports" is necessary to keep imports tidy.

heruan avatar Sep 12 '25 06:09 heruan