Logback依赖性阻止SBT脱机运行 [英] Logback dependency preventing SBT running offline
问题描述
这是对上一个问题的改进,并且对该问题的归属也更紧密.
我试图确认我可以离线运行SBT项目.我可以,除非logback是我的libraryDependencies之一.为什么logback会引发问题?我已经做了一个简单的示例,其中仅包含一个build.sbt和一个"hello world"应用程序...
build.sbt ,带有一堆随机相关性以证明这一点:
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"
)
我的步骤
- 请确保在我的项目中删除
~/.ivy2
,~/.sbt
和target/
- 确保已连接到Internet,然后执行
sbt run
.我的问候世界成功运行 - 断开与互联网的连接
-
sbt clean
-
sbt run
.构建失败,并以未解决的依赖关系重新登录 - 删除logback依赖性,然后再次
sbt run
.你好,世界奔跑.
这是步骤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
更新:
在SBT中使用last
命令,有 lot 条调试信息用于依赖性解析.这是Akka成功解析的示例:
[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(*)]
这是登录失败的原因
[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
我可以确认缓存中的以下文件(不是'〜/.ivy/local'文件夹):
~/.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
当我尝试使用该文件时,确实从〜/.ivy2/cache解析了该文件.我没有〜/.ivy2/local,因为我没有在本地发布.是否可能有一个ivysettings.xml文件(在Linux上,请尝试locate ivysettings.xml
)与某些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
- Delete
~/.ivy2
,~/.sbt
, andtarget/
inside my project, just to be sure - Ensure connected to the internet, and do
sbt run
. My hello world runs successfully - Disconnect from internet
sbt clean
sbt run
. Build fails with logback as an unresolved dependency- 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
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.
这篇关于Logback依赖性阻止SBT脱机运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!