question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SBT reload fails on SNAPSHOT which are republished locally *while SBT runs*

See original GitHub issue

I’m developing a SBT plugin and testing it by reloading in a project using it. The reload however fails, complaining about corruption of the plugin JAR file, and I must exit and re-enter the client SBT project; this happened with SBT 0.13.0 in the client, and 0.12.4 in the SBT used for development.

The first time, the client SBT complained that it can’t find sbt/sbt.plugins within the JAR. But unzip confirms the entry is there; exiting and re-entering SBT in the client project fixes the problem. The second time, the error was different, but again unzip -t confirms that the JAR is fine. The third time, the error was yet different, but again about ZIP corruption.

Note that before the failed reload, lsof reveals that SBT has two file descriptors pointing at the JAR of the plugin, while afterwards it has three or four file descriptors. My suspect is that it does not reopen the JAR file from scratch, but tries to reuse some old info about it.

To support this hypothesis, this only happens if settings from the plugin are actually used (by putting seq($thisPluginSettings: _*) in build.sbt).

Steps to reproduce in my case:

git clone git@github.com:softprops/np.git
cd np
# edit build.sbt, set version to 0.2.1-SNAPSHOT
# edit plugins/plugins.sbt, comment out gpg plugin
sbt
> publish-local
# Close this or leave it open, we'll need it later.
# Go to another project, even a fresh one
# in project/plugins.sbt, add:
addSbtPlugin("me.lessis" % "np" % "0.2.1-SNAPSHOT")
# in build.sbt, add:
seq(npSettings: _*)
# Start sbt
# Go back to first console, reopen SBT or reuse the existing session (it doesn't matter), modify some source to force recompilation, perform publish-local
# Go back to second console
# Try using the plugin, it still works if used before, otherwise gives ClassNotFoundException.
# Try a reload, get some error about corruption of the ZIP file, for instance:

> reload
[info] Loading global plugins from /Users/pgiarrusso/.sbt/0.13/plugins
[info] Updating {file:/Users/pgiarrusso/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[error] java.io.FileNotFoundException: JAR entry sbt/sbt.plugins not found in /Users/pgiarrusso/.ivy2/local/me.lessis/np/scala_2.10/sbt_0.13/0.2.1-SNAPSHOT/jars/np.jar
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
# Press i to ignore
# Try using the plugin, get ClassNotFoundException:
> np::scout
[error] java.lang.NoClassDefFoundError: np/Plugin$$anonfun$npSettings0$2$$anonfun$apply$2$$anonfun$apply$3
[error] Use 'last' for the full log.

Error message 1:

java.io.FileNotFoundException: JAR entry sbt/sbt.plugins not found in /Users/pgiarrusso/.ivy2/local/me.lessis/np/scala_2.10/sbt_0.13/0.2.1-SNAPSHOT/jars/np.jar
    at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:140)
    at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:150)
    at java.net.URL.openStream(URL.java:1037)
    at sbt.Using$$anonfun$urlReader$1.apply(Using.scala:87)
    at sbt.Using$$anonfun$urlReader$1.apply(Using.scala:87)
    at sbt.Using$$anon$3.open(Using.scala:65)
    at sbt.Using.apply(Using.scala:24)
    at sbt.IO$.readLinesURL(IO.scala:669)
    at sbt.Load$$anonfun$binaryPlugins$2.apply(Load.scala:630)
    at sbt.Load$$anonfun$binaryPlugins$2.apply(Load.scala:629)
    at scala.collection.immutable.Stream$$anonfun$flatMap$1.apply(Stream.scala:450)
    at scala.collection.immutable.Stream$$anonfun$flatMap$1.apply(Stream.scala:450)
    at scala.collection.immutable.Stream.append(Stream.scala:237)
    at scala.collection.immutable.Stream$$anonfun$append$1.apply(Stream.scala:237)
    at scala.collection.immutable.Stream$$anonfun$append$1.apply(Stream.scala:237)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1085)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1077)
    at scala.collection.immutable.Stream$$anonfun$$plus$plus$1.apply(Stream.scala:330)
    at scala.collection.immutable.Stream$$anonfun$$plus$plus$1.apply(Stream.scala:330)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1085)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1077)
    at scala.collection.immutable.Stream$$anonfun$scala$collection$immutable$Stream$$loop$4$1.apply(Stream.scala:850)
    at scala.collection.immutable.Stream$$anonfun$scala$collection$immutable$Stream$$loop$4$1.apply(Stream.scala:850)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1085)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1077)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:376)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:376)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1085)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1077)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:376)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:376)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1085)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1077)
    at scala.collection.immutable.Stream.force(Stream.scala:249)
    at scala.collection.immutable.Stream.mkString(Stream.scala:702)
    at sbt.BuildUtil$.importAll(BuildUtil.scala:65)
    at sbt.BuildUtil$.importAllRoot(BuildUtil.scala:66)
    at sbt.Load$.buildGlobalSettings(Load.scala:80)
    at sbt.Load$.loadGlobalSettings(Load.scala:74)
    at sbt.Load$.defaultWithGlobal(Load.scala:68)
    at sbt.Load$.defaultLoad(Load.scala:38)
    at sbt.BuiltinCommands$.doLoadProject(Main.scala:434)
    at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:428)
    at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:428)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$.process(Command.scala:95)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:87)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:87)
    at sbt.State$$anon$1.process(State.scala:176)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:87)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:87)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.MainLoop$.next(MainLoop.scala:87)
    at sbt.MainLoop$.run(MainLoop.scala:80)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:69)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:66)
    at sbt.Using.apply(Using.scala:25)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:66)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:49)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:33)
    at sbt.MainLoop$.runLogged(MainLoop.scala:25)
    at sbt.xMain.run(Main.scala:26)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
    at xsbt.boot.Launch$.run(Launch.scala:57)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:65)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:32)
    at xsbt.boot.Boot$.main(Boot.scala:21)
    at xsbt.boot.Boot.main(Boot.scala)
[error] java.io.FileNotFoundException: JAR entry sbt/sbt.plugins not found in /Users/pgiarrusso/.ivy2/local/me.lessis/np/scala_2.10/sbt_0.13/0.2.1-SNAPSHOT/jars/np.jar
[error] Use 'last' for the full log.

Error message 2:

java.util.zip.ZipException: invalid stored block lengths
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at java.io.BufferedReader.fill(BufferedReader.java:154)
    at java.io.BufferedReader.readLine(BufferedReader.java:317)
    at java.io.BufferedReader.readLine(BufferedReader.java:382)
    at sbt.IO$.readLine$1(IO.scala:689)
    at sbt.IO$.foldLines(IO.scala:692)
    at sbt.IO$.readLines(IO.scala:677)
    at sbt.IO$$anonfun$readLinesURL$1.apply(IO.scala:669)
    at sbt.IO$$anonfun$readLinesURL$1.apply(IO.scala:669)
    at sbt.Using.apply(Using.scala:25)
    at sbt.IO$.readLinesURL(IO.scala:669)
    at sbt.Load$$anonfun$binaryPlugins$2.apply(Load.scala:630)
    at sbt.Load$$anonfun$binaryPlugins$2.apply(Load.scala:629)
    at scala.collection.immutable.Stream$$anonfun$flatMap$1.apply(Stream.scala:450)
    at scala.collection.immutable.Stream$$anonfun$flatMap$1.apply(Stream.scala:450)
    at scala.collection.immutable.Stream.append(Stream.scala:237)
    at scala.collection.immutable.Stream$$anonfun$append$1.apply(Stream.scala:237)
    at scala.collection.immutable.Stream$$anonfun$append$1.apply(Stream.scala:237)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1085)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1077)
    at scala.collection.immutable.Stream$$anonfun$$plus$plus$1.apply(Stream.scala:330)
    at scala.collection.immutable.Stream$$anonfun$$plus$plus$1.apply(Stream.scala:330)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1085)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1077)
    at scala.collection.immutable.Stream$$anonfun$scala$collection$immutable$Stream$$loop$4$1.apply(Stream.scala:850)
    at scala.collection.immutable.Stream$$anonfun$scala$collection$immutable$Stream$$loop$4$1.apply(Stream.scala:850)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1085)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1077)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:376)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:376)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1085)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1077)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:376)
    at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:376)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1085)
    at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1077)
    at scala.collection.immutable.Stream.force(Stream.scala:249)
    at scala.collection.immutable.Stream.mkString(Stream.scala:702)
    at sbt.BuildUtil$.importAll(BuildUtil.scala:65)
    at sbt.BuildUtil$.importAllRoot(BuildUtil.scala:66)
    at sbt.Load$.buildGlobalSettings(Load.scala:80)
    at sbt.Load$.loadGlobalSettings(Load.scala:74)
    at sbt.Load$.defaultWithGlobal(Load.scala:68)
    at sbt.Load$.defaultLoad(Load.scala:38)
    at sbt.BuiltinCommands$.doLoadProject(Main.scala:434)
    at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:428)
    at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:428)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$.process(Command.scala:95)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:87)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:87)
    at sbt.State$$anon$1.process(State.scala:176)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:87)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:87)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.MainLoop$.next(MainLoop.scala:87)
    at sbt.MainLoop$.run(MainLoop.scala:80)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:69)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:66)
    at sbt.Using.apply(Using.scala:25)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:66)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:49)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:33)
    at sbt.MainLoop$.runLogged(MainLoop.scala:25)
    at sbt.xMain.run(Main.scala:26)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
    at xsbt.boot.Launch$.run(Launch.scala:57)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:65)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:32)
    at xsbt.boot.Boot$.main(Boot.scala:21)
    at xsbt.boot.Boot.main(Boot.scala)

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
reid-spencercommented, Jul 3, 2015

+1 I know this has been ignored mostly but has anyone found a workaround? The only workaround I have today is to restart sbt

1reaction
rbellamycommented, Jan 18, 2017

This makes testing newly published plugins locally, in a “real” SBT project (e.g. not a sbt-scripted test project) very difficult.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IDEA doesn't resolve properly locally published snapshots
In the project that is using that dependency, IDEA cannot correctly autocomplete the code for the updated snapshot dependency that is local only...
Read more >
SBT: How to ensure that local snapshot dependency is picked ...
Try setting coursier TTL to 0 seconds in build.sbt import scala.concurrent.duration.DurationInt import lmcoursier.definitions.
Read more >
sbt Reference Manual — Combined Pages
Use the reload command to reflect the change in build.sbt . ... Make a command run when one or more source files change...
Read more >
Speed up things in scalac and sbt - kubuszok.com
I mentioned that snapshots are bad, but why? If you are loading you project the first time (or after some changes to dependencies),...
Read more >
sbt | Metals - Scalameta
Metals run sbt in a separate process and this error happens where there are two sbt processes resolving dependencies at the same time....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found