scalacenter / scalafix

Refactoring and linting tool for Scala

Home Page:https://scalacenter.github.io/scalafix/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Triggers "no SLF4j binding found" on SBT 1.7.3

LeifW opened this issue · comments

On upgrading to SBT 1.7.3 (didn't happen in 1.7.2), you get a warning from SLF4J on startup of SBT if sbt-scalafix is in project/plugins.sbt:

SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J: Ignoring binding found at [jar:file:/home/leif/.sbt/boot/scala-2.12.17/org.scala-sbt/sbt/1.7.3/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.

Adding slf4j-simple, slf4j-nop, or logback-classic to project/plugins.sbt doesn't fix this.

Thanks for the report!

sbt-scalafix does depend on slf4j through jgit

$ cs resolve --what-depends-on org.slf4j:slf4j-api --sbt-plugin ch.epfl.scala:sbt-scalafix:0.10.4
  Result:
└─ org.slf4j:slf4j-api:1.7.30
   └─ org.eclipse.jgit:org.eclipse.jgit:5.13.1.202206130422-r
      └─ ch.epfl.scala:sbt-scalafix;sbtVersion=1.0;scalaVersion=2.12:0.10.4

It looks like sbt 1.7.3 contains an evicted slf4j (following the recent coursier bump), without the corresponding log4j-slf4j2-impl (only log4j-slf4j-impl is injected).

$ cs resolve --what-depends-on org.slf4j:slf4j-api org.scala-sbt:sbt:1.7.3
  Result:
└─ org.slf4j:slf4j-api:2.0.3
   ├─ com.eed3si9n:gigahorse-core_2.12:0.7.0 org.slf4j:slf4j-api:1.7.28 -> 2.0.3
   │  └─ com.eed3si9n:gigahorse-apache-http_2.12:0.7.0
   │     └─ org.scala-sbt:librarymanagement-core_2.12:1.7.1
   │        ├─ org.scala-sbt:actions_2.12:1.7.3
   │        │  └─ org.scala-sbt:main_2.12:1.7.3
   │        │     └─ org.scala-sbt:sbt:1.7.3
   │        ├─ org.scala-sbt:command_2.12:1.7.3
   │        │  ├─ org.scala-sbt:main-settings_2.12:1.7.3
   │        │  │  └─ org.scala-sbt:main_2.12:1.7.3
   │        │  │     └─ org.scala-sbt:sbt:1.7.3
   │        │  └─ org.scala-sbt:main_2.12:1.7.3
   │        │     └─ org.scala-sbt:sbt:1.7.3
   │        ├─ org.scala-sbt:librarymanagement-ivy_2.12:1.7.1
   │        │  ├─ io.get-coursier:lm-coursier-shaded_2.12:2.0.12 org.scala-sbt:librarymanagement-ivy_2.12:1.3.4 -> 1.7.1
   │        │  │  └─ org.scala-sbt:main_2.12:1.7.3
   │        │  │     └─ org.scala-sbt:sbt:1.7.3
   │        │  └─ org.scala-sbt:main_2.12:1.7.3
   │        │     └─ org.scala-sbt:sbt:1.7.3
   │        ├─ org.scala-sbt:main-settings_2.12:1.7.3
   │        │  └─ org.scala-sbt:main_2.12:1.7.3
   │        │     └─ org.scala-sbt:sbt:1.7.3
   │        ├─ org.scala-sbt:main_2.12:1.7.3
   │        │  └─ org.scala-sbt:sbt:1.7.3
   │        └─ org.scala-sbt:zinc-lm-integration_2.12:1.7.3
   │           └─ org.scala-sbt:main_2.12:1.7.3
   │              └─ org.scala-sbt:sbt:1.7.3
   ├─ io.get-coursier:lm-coursier-shaded_2.12:2.0.12
   │  └─ org.scala-sbt:main_2.12:1.7.3
   │     └─ org.scala-sbt:sbt:1.7.3
   └─ org.apache.logging.log4j:log4j-slf4j-impl:2.17.1 org.slf4j:slf4j-api:1.7.25 -> 2.0.3
      └─ org.scala-sbt:main_2.12:1.7.3
         └─ org.scala-sbt:sbt:1.7.3

Adding slf4j-simple, slf4j-nop, or logback-classic to project/plugins.sbt doesn't fix this.

Indeed, and neither does adding log4j-slf4j2-impl. I assume it's because sbt is doing some funky classloading stuff.

Let's keep an eye on the discussion upstream sbt/sbt#7062

Fixed in sbt 1.8.1 thanks to sbt/sbt#7116