Scala-cli fmt runner.dialectOverride problem

Hello Everyone

I cannot get the scala-cli fmt with .scalafmt.conf file working correctly … I have …
$ scala-cli --version
Scala CLI version 1.3.2
Scala version (default):3.4.2

I have two files in a test directory

  1. An empty Test.scala file.
  2. .scalafmt.conf (simplified to try and isolate problem) which is this…

version = “3.8.0”
project.git = true
runner.dialect = scala3
rewrite.scala3.convertToNewSyntax = true
runner.dialectOverride.withAllowToplevelTerms = true
project.excludeFilters = [ “.*/build\.sc” ]

At a command prompt in the test directory I do …
scala-cli fmt Test.scala
… I get …
scala.meta.Dialect.withAllowToplevelTerms(boolean)

… which I believe is “Error 8”.
Also a new directory is created “.scala-build” containing a copy of .scalafmt.conf
I get the same problem with “proper scala files”, so I don’t think the empty test file is relevant. I get the same problem with other “runner.dialectOverride options”.

Q1) Are there any debugging techniques I can use to find my problem ?
Q2) Does anyone have an example .scalafmt.conf file that might help me ?
Q3) Any other suggestions ?

It seems that runner.dialectOverride.withAllowToplevelTerms = true is causing issues and we should take a look at that. Most likely it’s scala-cli fmt not working with rewrite. · Issue #2684 · VirtusLab/scala-cli · GitHub

Do you need to add that setting though? I think everything should be properly formatted anyway without it.

Alternatively, you can use the default scalafmt cli available via coursier or to download in scalafmt repo.

1 Like

Hi tgodzik,
Thank you for analysing and responding to my scala-cli fmt issue. I followed your advice and I now format my scala files using “scalafmt”. The same .conf file works fine… In addition, a more complicated .scalafmt.conf file (the original before simplifying to highlight issue) also works :smiley:
JohnP

1 Like