0

In an sbt project, I'm adding some plugins, like

addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.2")

This should resolve to an artifact url similar to this:

https://repo1.maven.org/maven2/org/typelevel/sbt-tpolecat_2.12_1.0/0.5.2/sbt-tpolecat_2.12_1.0-0.5.2.pom

But instead it is trying this url and fails:

[error] Error downloading org.typelevel:sbt-tpolecat;sbtVersion=1.0;scalaVersion=2.12:0.5.2
[error]   not found: https://repo1.maven.org/maven2/org/typelevel/sbt-tpolecat/0.5.2/sbt-tpolecat-0.5.2.pom

This is with Java 21.0.7, Scala 3.6.1 and sbt 1.11.2 on MacOS.

1
  • 3
    Where did you add that line? What is your sbt version? Which command did you run? Commented Jul 2 at 20:50

2 Answers 2

3

Please double check that you're adding the line addSbtPlugin(...) to the file project/plugins.sbt (or project/build.sbt), not root build.sbt, i.e. to a build file of the meta-project, not to a build file of the project itself: sbt is recursive.

addSbtPlugin(...) is actually a wrapper over libraryDependencies += ...

  /**
   * Adds `dependency` as an sbt plugin for the sbt and Scala versions configured by
   * `sbtBinaryVersion` and `scalaBinaryVersion` scoped to `update`.
   */
  def addSbtPlugin(dependency: ModuleID): Setting[Seq[ModuleID]] =
    libraryDependencies += {
      val sbtV = (pluginCrossBuild / sbtBinaryVersion).value
      val scalaV = (update / scalaBinaryVersion).value
      sbtPluginExtra(dependency, sbtV, scalaV)
    }

https://github.com/sbt/sbt/blob/v1.11.2/main/src/main/scala/sbt/Defaults.scala#L4587-L4596

If you're sure that the issue is that in the url https://repo1.maven.org/maven2/org/typelevel/sbt-tpolecat/0.5.2/sbt-tpolecat-0.5.2.pom (vs correct https://repo1.maven.org/maven2/org/typelevel/sbt-tpolecat_2.12_1.0/0.5.2/sbt-tpolecat_2.12_1.0-0.5.2.pom) the suffix _2.12_1.0 is not added then you can try

libraryDependencies += "org.typelevel" % "sbt-tpolecat_2.12_1.0" % "0.5.2"

in project/plugins.sbt (that's what addSbtPlugin is supposed to do).

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, thank you, I've been adding the suffix to my plugins as a workaround, but I found the source issue, please see below.
2

Turns out that I run a scala-cli command some days ago to set the default repository to some internal url... something like:

scala-cli config --power repositories.default https://<internal_url>

For some reason that seems to mess with the resolver pattern, and also messed with the repository mirrors. I went to the actual config file at ~/Library/Application Support/ScalaCli/secrets/config.json and commented out the setting, that fixed it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.