Logback dependency preventing SBT running offline

…衆ロ難τιáo~ 提交于 2019-12-10 11:25:56

问题


This is a refinement of a previous question with closer attribution to the problem.

I'm trying to confirm I can run my SBT project offline. I can, unless logback is one of my libraryDependencies. Why is logback triggering a problem? I've made a simple example consisting of just a build.sbt and a 'hello world' app...

build.sbt with a bunch of random dependencies to prove the point:

name := "testProject"

version := "0.0.1"

scalaVersion := "2.10.3"

libraryDependencies ++= Seq(
    "org.apache.commons" % "commons-math3" % "3.2",
    "com.amazonaws" % "aws-java-sdk" % "1.4.0.1",
    "ch.qos.logback" % "logback-classic" % "1.1.1",
    "com.typesafe.akka" %% "akka-actor" % "2.3.1", 
    "com.typesafe.akka" %% "akka-remote" % "2.3.1",
    "org.scalaz" %% "scalaz-core" % "7.0.3"
)

My steps

  1. Delete ~/.ivy2, ~/.sbt, and target/ inside my project, just to be sure
  2. Ensure connected to the internet, and do sbt run. My hello world runs successfully
  3. Disconnect from internet
  4. sbt clean
  5. sbt run. Build fails with logback as an unresolved dependency
  6. Remove the logback dependency and sbt run again. Hello world runs.

This is the error from step 5:

[info] Resolving ch.qos.logback#logback-classic;1.1.1 ...
[warn] Host repo1.maven.org not found. url=http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.pom
[info] You probably access the destination server through a proxy server that is not well configured.
[warn]  module not found: ch.qos.logback#logback-classic;1.1.1
[warn] ==== local: tried
[warn]   /home/user/.ivy2/local/ch.qos.logback/logback-classic/1.1.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: ch.qos.logback#logback-classic;1.1.1: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
sbt.ResolveException: unresolved dependency: ch.qos.logback#logback-classic;1.1.1: not found

Update:

Using the last command in SBT there is a lot of debug info for dependency resolution. Here's an example of Akka resolving successfully:

[info] Resolving com.typesafe.akka#akka-actor_2.10;2.3.1 ...
[debug] sbt-chain: Checking cache for: dependency: com.typesafe.akka#akka-actor_2.10;2.3.1 {compile=[default(compile)]}
[debug] sbt-chain: module revision found in cache: com.typesafe.akka#akka-actor_2.10;2.3.1
[debug]     local: revision in cache: com.typesafe.akka#akka-actor_2.10;2.3.1
[debug]     found com.typesafe.akka#akka-actor_2.10;2.3.1 in sbt-chain
[debug] == resolving dependencies testproject#testproject_2.10;0.0.1->com.typesafe.akka#akka-actor_2.10;2.3.1 [compile->runtime]
[debug] == resolving dependencies testproject#testproject_2.10;0.0.1->com.typesafe.akka#akka-actor_2.10;2.3.1 [compile->compile]
[debug] == resolving dependencies com.typesafe.akka#akka-actor_2.10;2.3.1->org.scala-lang#scala-library;2.10.3 [compile->master(*)]
[debug] == resolving dependencies com.typesafe.akka#akka-actor_2.10;2.3.1->org.scala-lang#scala-library;2.10.3 [compile->compile(*)]
[debug] == resolving dependencies com.typesafe.akka#akka-actor_2.10;2.3.1->com.typesafe#config;1.2.0 [compile->master(*)]

Here's the failure for Logback:

[info] Resolving ch.qos.logback#logback-classic;1.1.1 ...
[debug] sbt-chain: Checking cache for: dependency: ch.qos.logback#logback-classic;1.1.1 {compile=[default(compile)]}
[debug]         tried /home/user/.ivy2/local/ch.qos.logback/logback-classic/1.1.1/ivys/ivy.xml
[debug]     local: no ivy file found for ch.qos.logback#logback-classic;1.1.1
[debug]         tried http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.pom
[warn] Host repo1.maven.org not found. url=http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.pom
[info] You probably access the destination server through a proxy server that is not well configured.
[debug]     public: no ivy file found for ch.qos.logback#logback-classic;1.1.1
[warn]  module not found: ch.qos.logback#logback-classic;1.1.1
[warn] ==== local: tried
[warn]   /home/user/.ivy2/local/ch.qos.logback/logback-classic/1.1.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.pom

I can confirm the following files in the cache (not the '~/.ivy/local' folder):

~/.ivy2/cache/ch.qos.logback/logback-classic$ ls
ivy-1.1.1.xml  ivy-1.1.1.xml.original  ivydata-1.1.1.properties  jars

回答1:


When I try it, the file is indeed resolved from ~/.ivy2/cache. I have no ~/.ivy2/local because I do not publish locally. Is it possible that you have an ivysettings.xml file (on Linux, try locate ivysettings.xml) that is messing with some Ivy cache attribute, like resolutionCacheDir? It would still be a mystery why you only have problems with that one jar....

UPDATE: This appears to be a regression in SBT 0.13.1; it worked in 0.13.0, and as the OP himself discovered (see his answer), it was fixed in 0.13.2.




回答2:


It can't find it in your local ivy cache, fix that and you've solved your problem.

Try clearing out your ivy cache, maybe it's corrupt.




回答3:


SBT 0.13.2 was released 3 days after this question, and seems to resolve the problem. I don't know if this was a known issue, but the changes listed for SBT 0.13.2 include

Fix issue where ivy's .+ dependency ranges were not correctly translated to maven.



来源:https://stackoverflow.com/questions/23020066/logback-dependency-preventing-sbt-running-offline

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!