-
Notifications
You must be signed in to change notification settings - Fork 283
Closed
Description
This issue is observable in the following configuration
- latest version of CLI and previous version in
.scalafmt.conf
Configuration (required)
version = 3.8.3
runner.dialect = scala3
...
rewrite.scala3.convertToNewSyntax = true
rewrite.scala3.removeOptionalBraces = falseCommand-line parameters (required)
When I run scalafmt via CLI like this: scalafmt --diff-branch origin/master
Steps
Given a GitHub workflow
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: coursier/setup-action@v1
with:
jvm: temurin:21
apps: scalafmt
- run: scalafmt --diff-branch origin/masterProblem
When running scalafmt when a PR is raised via
Run scalafmt --diff-branch origin/master
scalafmt --diff-branch origin/master
shell: /usr/bin/bash -e {0}
env:
JAVA_HOME: /home/runner/.cache/coursier/arc/https/github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%252B11/OpenJDK21U-jdk_x64_linux_hotspot_21.0.5_11.tar.gz/jdk-21.0.5+11
COURSIER_BIN_DIR: /home/runner/cs/bin
I get the following error
Exception in thread "main" java.lang.Exception: Can't use different version for native CLI
at org.scalafmt.interfaces.Scalafmt$.create(Scalafmt.scala:142)
at org.scalafmt.interfaces.Scalafmt.create(Scalafmt.scala)
at org.scalafmt.cli.ScalafmtDynamicRunner$.run(ScalafmtDynamicRunner.scala:21)
at org.scalafmt.cli.Cli$.runWithRunner(Cli.scala:134)
at org.scalafmt.cli.Cli$.run(Cli.scala:61)
at org.scalafmt.cli.Cli$.mainWithOptions(Cli.scala:35)
at org.scalafmt.cli.Cli$.main(Cli.scala:18)
at org.scalafmt.cli.Cli.main(Cli.scala)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at coursier.bootstrap.launcher.a.a(Unknown Source)
at coursier.bootstrap.launcher.Launcher.main(Unknown Source)
Expectation
I expect scalafmt to format the code or just do nothing
Run scalafmt --diff-branch origin/master
scalafmt --diff-branch origin/master
shell: /usr/bin/bash -e {0}
env:
JAVA_HOME: /home/runner/.cache/coursier/arc/https/github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%252B11/OpenJDK21U-jdk_x64_linux_hotspot_21.0.5_11.tar.gz/jdk-21.0.5+11
COURSIER_BIN_DIR: /home/runner/cs/bin
Reformatting...Workaround
I've found that by setting scalafmt version in .scalafmt.conf to the latest 3.4.2-RC2 the issue doesn't happen anymore
Notes
My assumption is that coursier pulls the latest scalafmt-cli as it's configured to latest.release
This only started happening yesterday, probably after 3.8.4-RC2 release, because there were no problems when 3.8.4-RC1 was the latest.
The same issue happens when running scala-steward from GitHub Actions when it tries to reformat changes
2024-11-20 09:05:57,595 INFO Found 1 update:
io.github.embeddedkafka:(embedded-kafka, embedded-kafka_2.13) : 3.8.1 -> 3.9.0
2024-11-20 09:05:57,599 INFO Process update io.github.embeddedkafka:(embedded-kafka, embedded-kafka_2.13) : 3.8.1 -> 3.9.0
2024-11-20 09:05:57,833 INFO Create branch update/embedded-kafka-3.9.0
2024-11-20 09:05:58,814 WARN Reformatting changed files failed in .
org.scalasteward.core.io.process$ProcessFailedException: '"SBT_OPTS=-Xmx2048m -Xss8m -XX:MaxMetaspaceSize=512m" scalafmt --non-interactive --mode changed' exited with code 1.
Error: Exception in thread "main" java.lang.Exception: Can't use different version for native CLI
at org.scalafmt.interfaces.Scalafmt$.create(Scalafmt.scala:142)
at org.scalafmt.interfaces.Scalafmt.create(Scalafmt.scala)
alexarchambault
Metadata
Metadata
Assignees
Labels
No labels