scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

scala-cli fmt not working with rewrite.

Open He-Pin opened this issue 1 year ago • 4 comments

Version(s) 1.1.1 Describe the bug

PS C:\Users\hepin\IdeaProjects\incubator-pekko> scala-cli fmt
scala.meta.Dialect.withAllowAsForImportRename(boolean)

Run scala-cli fmt on Windows ,only prints this line above, no formatting.

With:

rewrite.scala3.convertToNewSyntax = false
runner {
  dialectOverride {
    allowAsForImportRename = false
    allowStarWildcardImport = false
    allowPostfixStarVarargSplices = false
  }
}

It works when run in sbt shell.

To Reproduce Change the .sbtfmt.conf in pekko project. and run scala-cli fmt.

Expected behaviour Should be ok

He-Pin avatar Jan 16 '24 18:01 He-Pin

Some notes after a quick spike

  • this is specific to the scalafmt native launcher (https://github.com/VirtusLab/scalafmt-native-image)
  • as we have no native launcher for M1/aarch64, Scala CLI defaults to the JVM launcher for that platform and thus, this is not replicable on M1 machines (unless you download the native launcher manually and replicate the problem with that)
  • the error we are getting seems to be the same one as when passing an invalid key in the configuration, which implies this particular key does not exist in the scalafmt-native-image launcher
  • I've no idea what could be causing this

Potential further steps:

  • figure out what's different about scalafmt-native-image (perhaps we're accidentally using a wrong version of some dependency in there?)
  • add a flag to force the platform for the scalafmt launcher, so that we have a workaround with the JVM launcher (ugh)

Gedochao avatar Feb 01 '24 14:02 Gedochao

Thanks, and I's using Window 11, and thanks for this great tool.

He-Pin avatar Feb 01 '24 17:02 He-Pin

Optimally, this should be fixed by bringing https://github.com/scalameta/scalafmt/pull/2846 to a closure.

Gedochao avatar Apr 12 '24 08:04 Gedochao