Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sbt fails under FreeBSD with 'java.nio.file.NoSuchFileException: <PATH>/project/target/scala-2.12/sbt-1.0/classes #3894

Closed
j-keck opened this issue Jan 20, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@j-keck
Copy link
Contributor

commented Jan 20, 2018

after i create the directory by hand, sbt compiles and run's my project.

steps

To trigger the error under Linux, you need a new project and start sbt with 'sbt.io.jdktimestamps=true':

mkdir -p /tmp/sbt-javamillis; cd /tmp/sbt-javamillis
echo 'name := "sbt-javamillis"' > build.sbt
mkdir project; echo sbt.version=1.1.0 > project/build.properties
sbt -Dsbt.io.jdktimestamps=true

problem

For FreeBSD there is no native handling for file-timestamps (in sbt.internal.io.Milli) so the
pure Java implementation with java.nio.files.Files are used.

The native implementations throws a java.io.FileNotFoundException where the
Java implementation throws java.nio.file.NoSuchFileException if the given file doesn't exists.

sbt.io.IO.getModifiedTimeOrZero and sbt.io.IO.setModifiedTimeOrFalse catch only java.io.FileNotFoundException - so the java.nio.file.NoSuchFileException are propagated.

expectation

sbt should work under FreeBSD without to create a directory by hand.

notes

sbt version: 1.1.0
FreeBSD 11.1-STABLE #6 r327415+2236b971aa20(stable/11): Fri Jan 19 16:58:54 CET 2018 root@main.locweb:/usr/obj/usr/src/sys/J

stacktrace

[info] Loading settings from sbt-updates.sbt,plugins.sbt,idea.sbt,coursier.sbt ...
[info] Loading global plugins from /usr/home/j/.sbt/1.0/plugins
[info] Loading project definition from /tmp/sbt-javamillis/project
[error] java.nio.file.NoSuchFileException: /tmp/sbt-javamillis/project/target/scala-2.12/sbt-1.0/classes
[error] 	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
[error] 	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
[error] 	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
[error] 	at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
[error] 	at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
[error] 	at java.nio.file.Files.readAttributes(Files.java:1737)
[error] 	at java.nio.file.Files.getLastModifiedTime(Files.java:2266)
[error] 	at sbt.internal.io.JavaMilli$.getModifiedTime(Milli.scala:321)
[error] 	at sbt.internal.io.Milli$.getModifiedTime(Milli.scala:352)
[error] 	at sbt.io.IO$.getModifiedTime(IO.scala:1143)
[error] 	at sbt.io.IO$.getModifiedTimeOrZero(IO.scala:1212)
[error] 	at sbt.compiler.Eval$.fileModifiedBytes(Eval.scala:491)
[error] 	at sbt.compiler.Eval.$anonfun$evalCommon$2(Eval.scala:165)
[error] 	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
[error] 	at scala.collection.immutable.List.foreach(List.scala:389)
[error] 	at scala.collection.TraversableLike.map(TraversableLike.scala:234)
[error] 	at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
[error] 	at scala.collection.immutable.List.map(List.scala:295)
[error] 	at sbt.compiler.Eval$.seqBytes(Eval.scala:482)
[error] 	at sbt.compiler.Eval.evalCommon(Eval.scala:165)
[error] 	at sbt.compiler.Eval.eval(Eval.scala:119)
[error] 	at sbt.internal.EvaluateConfigurations$.evaluateDslEntry(EvaluateConfigurations.scala:180)
[error] 	at sbt.internal.EvaluateConfigurations$.$anonfun$evaluateSbtFile$2(EvaluateConfigurations.scala:120)
[error] 	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
[error] 	at scala.collection.immutable.List.foreach(List.scala:389)
[error] 	at scala.collection.TraversableLike.map(TraversableLike.scala:234)
[error] 	at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
[error] 	at scala.collection.immutable.List.map(List.scala:295)
[error] 	at sbt.internal.EvaluateConfigurations$.evaluateSbtFile(EvaluateConfigurations.scala:118)
[error] 	at sbt.internal.Load$.loadSettingsFile$1(Load.scala:1087)
[error] 	at sbt.internal.Load$.$anonfun$discoverProjects$2(Load.scala:1095)
[error] 	at scala.collection.MapLike.getOrElse(MapLike.scala:128)
[error] 	at scala.collection.MapLike.getOrElse$(MapLike.scala:126)
[error] 	at scala.collection.AbstractMap.getOrElse(Map.scala:59)
[error] 	at sbt.internal.Load$.memoLoadSettingsFile$1(Load.scala:1094)
[error] 	at sbt.internal.Load$.$anonfun$discoverProjects$4(Load.scala:1102)
[error] 	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
[error] 	at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
[error] 	at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
[error] 	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
[error] 	at scala.collection.TraversableLike.map(TraversableLike.scala:234)
[error] 	at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
[error] 	at scala.collection.AbstractTraversable.map(Traversable.scala:104)
[error] 	at sbt.internal.Load$.loadFiles$1(Load.scala:1102)
[error] 	at sbt.internal.Load$.discoverProjects(Load.scala:1116)
[error] 	at sbt.internal.Load$.discover$1(Load.scala:844)
[error] 	at sbt.internal.Load$.loadTransitive(Load.scala:909)
[error] 	at sbt.internal.Load$.loadProjects$1(Load.scala:714)
[error] 	at sbt.internal.Load$.$anonfun$loadUnit$10(Load.scala:717)
[error] 	at sbt.internal.Load$.timed(Load.scala:1343)
[error] 	at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:717)
[error] 	at sbt.internal.Load$.timed(Load.scala:1343)
[error] 	at sbt.internal.Load$.loadUnit(Load.scala:677)
[error] 	at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:477)
[error] 	at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:158)
[error] 	at sbt.internal.BuildLoader.apply(BuildLoader.scala:223)
[error] 	at sbt.internal.Load$.loadURI$1(Load.scala:539)
[error] 	at sbt.internal.Load$.loadAll(Load.scala:555)
[error] 	at sbt.internal.Load$.loadURI(Load.scala:485)
[error] 	at sbt.internal.Load$.load(Load.scala:464)
[error] 	at sbt.internal.Load$.$anonfun$apply$1(Load.scala:253)
[error] 	at sbt.internal.Load$.timed(Load.scala:1343)
[error] 	at sbt.internal.Load$.apply(Load.scala:253)
[error] 	at sbt.internal.Load$.defaultLoad(Load.scala:69)
[error] 	at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:707)
[error] 	at sbt.BuiltinCommands$.doLoadProject(Main.scala:707)
[error] 	at sbt.BuiltinCommands$.$anonfun$loadProjectImpl$2(Main.scala:680)
[error] 	at sbt.Command$.$anonfun$applyEffect$4(Command.scala:134)
[error] 	at sbt.Command$.$anonfun$applyEffect$2(Command.scala:130)
[error] 	at sbt.MainLoop$.processCommand(MainLoop.scala:153)
[error] 	at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:136)
[error] 	at sbt.State$$anon$1.runCmd$1(State.scala:242)
[error] 	at sbt.State$$anon$1.process(State.scala:248)
[error] 	at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:136)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] 	at sbt.MainLoop$.next(MainLoop.scala:136)
[error] 	at sbt.MainLoop$.run(MainLoop.scala:129)
[error] 	at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:107)
[error] 	at sbt.io.Using.apply(Using.scala:22)
[error] 	at sbt.MainLoop$.runWithNewLog(MainLoop.scala:101)
[error] 	at sbt.MainLoop$.runAndClearLast(MainLoop.scala:57)
[error] 	at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:42)
[error] 	at sbt.MainLoop$.runLogged(MainLoop.scala:34)
[error] 	at sbt.StandardMain$.runManaged(Main.scala:113)
[error] 	at sbt.xMain.run(Main.scala:76)
[error] 	at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error] 	at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error] 	at xsbt.boot.Launch$.run(Launch.scala:109)
[error] 	at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] 	at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] 	at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] 	at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] 	at xsbt.boot.Boot$.main(Boot.scala:17)
[error] 	at xsbt.boot.Boot.main(Boot.scala)
[error] java.nio.file.NoSuchFileException: /tmp/sbt-javamillis/project/target/scala-2.12/sbt-1.0/classes
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? 
@cunei

This comment has been minimized.

Copy link
Contributor

commented Jan 22, 2018

Thanks for the report @j-keck. Actually, since you are using FreeBSD, we can also add the relevant native code; it should be rather easy. In theory, we should just need to add a variant of StatLong (assuming you are on x86_64), using different constants. Can you please let me know the output of the following test on your machine?

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <fcntl.h>
#include <sys/utsname.h>
#include <sys/stat.h>

int main(int ac, char**av) {
  struct utsname os;
  uname(&os);
  printf("Constants for: %s %s %s %s\n", os.sysname, os.release, os.version, os.machine);
  printf("offsets: %lu, %lu, %lu\n", sizeof(struct stat), offsetof(struct stat, st_mtim.tv_sec), offsetof(struct stat, st_mtim.tv_nsec));
  printf("UTIME_OMIT: 0x%8lx\n", UTIME_OMIT);
  printf("AT_FDCWD: %d\n", AT_FDCWD);
}
@j-keck

This comment has been minimized.

Copy link
Contributor Author

commented Jan 22, 2018

Constants for: FreeBSD 11.1-STABLE FreeBSD 11.1-STABLE #6 r327415+2236b971aa20(stable/11): Fri Jan 19 16:58:54 CET 2018     root@main.locweb:/usr/obj/usr/src/sys/J amd64
offsets: 120, 40, 48
UTIME_OMIT: 0xfffffffe
AT_FDCWD: -100
@cunei

This comment has been minimized.

Copy link
Contributor

commented Jan 22, 2018

Awesome! I'll prepare a patch for you to try.

@cunei

This comment has been minimized.

Copy link
Contributor

commented Jan 22, 2018

I tested the basic code in a VM, and it seems to work ok.

@j-keck Please let us know if you can test the pull request whenever you have some time. Thanks!

@j-keck

This comment has been minimized.

Copy link
Contributor Author

commented Jan 23, 2018

@cunei i currently compile sbt with your changes, and will test it later today. Thanks for your effort!

@cunei

This comment has been minimized.

Copy link
Contributor

commented Jan 23, 2018

The two PRs are merged, closing the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.