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

Running mill in source directory causes subsequent tasks to fail #823

Closed
yilinwei opened this issue Apr 20, 2020 · 8 comments · Fixed by #1878
Closed

Running mill in source directory causes subsequent tasks to fail #823

yilinwei opened this issue Apr 20, 2020 · 8 comments · Fixed by #1878

Comments

@yilinwei
Copy link

Reproduction can be found here.

I've not tested on a different computer or OS.

@lefou
Copy link
Member

lefou commented Apr 20, 2020

Thanks for reporting and providing a reproduction.

After a first glace, I think it's because mill creates a socket file under out/mill-worker-*/io, which is not readable as a source file.

@tfenne
Copy link

tfenne commented Aug 17, 2020

I just got caught out by this. Accidentally ran mill deep down in a source directory, then spent 10-15 minutes trying to figure out why mill was generating such a cryptic error before stumbling on this issue. Putting my stack trace here so it's easier for others to find when searching issues:

$ mill _.test
[32/55] tools.test.sources
1 targets failed
tools.test.sources java.nio.file.FileSystemException: [...]/src/test/scala/com/[...]/out/mill-worker-BzhyNALGB6i84adFWul54iUnoFc=-1/io: Operation not supported on socket

@lefou
Copy link
Member

lefou commented Aug 21, 2020

I'm not sure what the best approach is to solve this issue. Maybe we should filter out socket files when searching for source files? Or vice versa, explicitly only collect "real" files?

@tfenne
Copy link

tfenne commented Aug 21, 2020

I don't know the internals of mill very well, but I wonder if it would be possible to abort early if no build file can be found and simply not write anything in that case?

@lefou
Copy link
Member

lefou commented Mar 16, 2021

Yeah, exiting mill with a good message in case a build.sc is missing is a good idea.

@timshen24
Copy link

HelloWorld.sources java.nio.file.FileSystemException: /Users/.../MillTest1/HelloWorld/src/main/scala/hello/out/mill-worker-dRTtqvVZYalRvhruw0ZliMCsBnA=-1/io: Operation not supported on socket
java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
java.base/java.nio.file.Files.newByteChannel(Files.java:371)
java.base/java.nio.file.Files.newByteChannel(Files.java:422)
java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
java.base/java.nio.file.Files.newInputStream(Files.java:156)
os.Path.getInputStream(Path.scala:475)
os.read$inputStream$.apply(ReadWriteOps.scala:229)
mill.api.PathRef$.$anonfun$apply$2(PathRef.scala:47)
mill.api.PathRef$.$anonfun$apply$2$adapted(PathRef.scala:37)
scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
scala.collection.AbstractIterable.foreach(Iterable.scala:919)
scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:889)
mill.api.PathRef$.apply(PathRef.scala:37)
mill.scalalib.JavaModule.$anonfun$sources$4(JavaModule.scala:204)
mill.api.Result$Success.map(Result.scala:28)
mill.api.Result$Success.map(Result.scala:27)
mill.scalalib.JavaModule.$anonfun$sources$2(JavaModule.scala:204)
mill.define.Applicative$Applyer.$anonfun$zipMap$1(Applicative.scala:35)
mill.define.Task$MappedDest.evaluate(Task.scala:396)

I encountered the same problem, can anyone help me?

@lefou
Copy link
Member

lefou commented Oct 9, 2021

Just remove the src/main/scala/hello/out directory, which is obviously not part of your sources.

@lefou lefou added invalid This issue is invalid or lacks required information workaround-available and removed invalid This issue is invalid or lacks required information labels Oct 15, 2021
@lefou
Copy link
Member

lefou commented May 17, 2022

PR #1878 fixes this.

lefou added a commit that referenced this issue May 17, 2022
When creating a `PathRef` of a path that contains socket files, which is for example the case if the path contains the `out` directory of Mill, Mill is failing because it can't read the socket file to calculate the content digest. We already skip digesting of unreadable files but somehow those socket files are not marked as unreadable. There is no performant and platform neutral way to detect socket files, so this PR just catches the typical `FileSystemException` at `InputStream` creation time and gracefully handles it (like other unreadable files) by just ignoring its content.

* Fix #1875
* Fix #823

Pull request: #1878
@lefou lefou added this to the after 0.10.4 milestone May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants