无法将Cats从0.7.8升级到0.9.0

时间:2017-03-26 00:49:59

标签: scala scala-cats

我的项目使用的是Cats 0.7.8和Scala 2.11.8。如果我通过build.sbt文件更新并从

更改我的猫依赖项
"org.typelevel" % "cats-core_2.11" % "0.7.8"

"org.typelevel" % "cats-core_2.11" % "0.9.0"

然后尝试执行sbt clean compile我收到错误

[error] bad symbolic reference to cats.data.Xor encountered in class file 'Parser.class'.
[error] Cannot access type Xor in package cats.data. The current classpath may be
[error] missing a definition for cats.data.Xor, or Parser.class may have been compiled against a version that's
[error] incompatible with the one found on the current classpath.
[error] one error found
[error] (compile:compile) Compilation failed

问题是我不知道Parser.class是编译器所说的。我很确定我们自己的源代码库没有Parser.class。我们的代码不使用旧的Xor类Cats。 (虽然我们可以,因为我们还没有使用Scala 2.12。)

1 个答案:

答案 0 :(得分:1)

您使用的其他库可能也依赖于Cats。由于您通过添加自己的Cats版本来驱逐它的Cats版本,因此当您使编译器使用较新的版本时,该库会尝试链接旧版本。

您可以尝试使用像https://github.com/jrudolph/sbt-dependency-graph这样的SBT插件来打印整个关系图,然后检查哪些库也依赖于Cats。可能在其中一个旁边会有一个单词var newElem = document.createElement('div') newElem.textContent = 'newElem'; Array.prototype.forEach.call(document.querySelectorAll('header, main, footer'), function(c){ newElem.appendChild(c); }); document.body.appendChild(newElem); ,意味着它与其他版本的Cats链接而不是你提供的那个。

找到该库(ori库)后,尝试将它们更新为链接到较新Cats的较新版本。这就是我所能告诉你的,而不是自己看到其他依赖。