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

FileAlreadyExistsException on several parallel builds of the same project with Scala CLI #2549

Closed
Gedochao opened this issue Dec 31, 2024 · 1 comment
Milestone

Comments

@Gedochao
Copy link

Gedochao commented Dec 31, 2024

After exiting Bloop

scala-cli bloop exit --power

and then starting several (~20 on my local machine) parallel builds of the same, simple hello world script with Bloop, I'm getting

Error: Unexpected error when copying /Users/pchabelski/IdeaProjects/scala-cli/out/integration/tmpDirBase.dest/working-dir/run-601145553/test-2/.scala-build/.bloop/test-2_d3ad16f7cb-759f1d75c0/bloop-internal-classes/main-wj4lCK8TRUmv7JMKIj2d_w==/script$package.class to /Users/pchabelski/IdeaProjects/scala-cli/out/integration/tmpDirBase.dest/working-dir/run-601145553/test-2/.scala-build/test-2_d3ad16f7cb-759f1d75c0/classes/main/script$package.class, you might need to restart the build server.
java.nio.file.FileAlreadyExistsException: /Users/pchabelski/IdeaProjects/scala-cli/out/integration/tmpDirBase.dest/working-dir/run-601145553/test-2/.scala-build/test-2_d3ad16f7cb-759f1d75c0/classes/main/script$package.class
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:94)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixCopyFile.copyFile(UnixCopyFile.java:246)
        at java.base/sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:603)
        at java.base/sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:258)
        at java.base/java.nio.file.Files.copy(Files.java:1305)
        at bloop.io.ParallelOps$.copy$1(ParallelOps.scala:169)
        at bloop.io.ParallelOps$.$anonfun$copyDirectories$8(ParallelOps.scala:194)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at monix.eval.internal.TaskRunLoop$.startFuture(TaskRunLoop.scala:494)
        at monix.eval.Task.runToFutureOpt(Task.scala:586)
        at monix.eval.internal.TaskDeprecated$Extensions.runSyncMaybeOptPrv(TaskDeprecated.scala:128)
        at monix.eval.internal.TaskDeprecated$Extensions.$anonfun$coeval$1(TaskDeprecated.scala:303)
        at monix.eval.Coeval$Always.apply(Coeval.scala:1451)
        at monix.eval.Coeval.value(Coeval.scala:258)
        at bloop.io.ParallelOps$.$anonfun$copyDirectories$7(ParallelOps.scala:234)
        at monix.reactive.internal.consumers.ForeachAsyncConsumer$$anon$1.onNext(ForeachAsyncConsumer.scala:44)
        at monix.reactive.internal.consumers.LoadBalanceConsumer$$anon$1.$anonfun$signalNext$1(LoadBalanceConsumer.scala:218)
        at monix.execution.internal.InterceptRunnable.run(InterceptRunnable.scala:27)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

This seems to fail on

StandardCopyOption.REPLACE_EXISTING

Perhaps a lock on the file (per client) would make sense?

Relevant to:

cc @tgodzik

@tgodzik
Copy link
Contributor

tgodzik commented Jan 15, 2025

This should be fixed, there are some other problems, but they are more related to how Scala CLI modifies classfiles

@tgodzik tgodzik closed this as completed Jan 15, 2025
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

2 participants