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

Favor NIO over IO to avoid FileSystemExceptions on Windows #2566

Open
alexarchambault opened this issue Jan 10, 2025 · 0 comments
Open

Favor NIO over IO to avoid FileSystemExceptions on Windows #2566

alexarchambault opened this issue Jan 10, 2025 · 0 comments

Comments

@alexarchambault
Copy link
Contributor

On Windows, when Bloop compiled a project using a locally published JAR, it seems it still holds an exclusive access to the file. This is a problem when one wants to overwrite the locally published artifact from a build tool. One gets errors like

native.publishLocal java.nio.file.FileSystemException: C:\Users\Alex\.ivy2\local\io.github.alexarchambault.native-terminal\native-terminal\0.0.7-SNAPSHOT\jars\native-terminal.jar: The process cannot access the file because it is being used by another process
    java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
    java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
    java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
    java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:273)
    java.base/sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:104)
    java.base/java.nio.file.Files.delete(Files.java:1152)
    os.remove$all$.apply(FileOps.scala:341)
    os.copy$over$.apply(FileOps.scala:300)
    mill.scalalib.publish.LocalIvyPublisher.$anonfun$publishLocal$2(LocalIvyPublisher.scala:46)
    scala.collection.immutable.List.map(List.scala:247)
    scala.collection.immutable.List.map(List.scala:79)
    mill.scalalib.publish.LocalIvyPublisher.publishLocal(LocalIvyPublisher.scala:44)
    mill.scalalib.PublishModule.$anonfun$publishLocalTask$2(PublishModule.scala:231)

Restarting the Bloop server solves that problem, but isn't very handy.

Favoring Java NIO over Java IO seems to solve that problem, like done here or here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant