pub icon indicating copy to clipboard operation
pub copied to clipboard

Parallel invocations of `dart run`precompilation might interfere on windows

Open sigurdm opened this issue 2 years ago • 1 comments

From https://github.com/dart-lang/pub/issues/4070

We compile to a temporary file in each invocation, and rename to the destination. This gives the correct semantics on linux/macos (though it does more compilation work than necessary) but on windows if the destination is in use we will not be allowed to overwrite:

FAILURES!
Cannot rename file to 'C:\Dev\Google\dart-sdk\sdk\pkg\analysis_server\.dart_tool/pub\bin\test\test.dart-3.3.0-edge.6b5b3cc98a23afb58ffdaebf37941aed257ce885.snapshot', path = 'C:\Dev\Google\dart-sdk\sdk\pkg\analysis_server\.dart_tool/pub\bin\test\tmp5ae60430\test.dart-3.3.0-edge.6b5b3cc98a23afb58ffdaebf37941aed257ce885.snapshot.incremental.temp' (OS Error: Access is denied.
, errno = 5)
PathAccessException: Cannot rename file to 'C:\Dev\Google\dart-sdk\sdk\pkg\analysis_server\.dart_tool/pub\bin\test\test.dart-3.3.0-edge.6b5b3cc98a23afb58ffdaebf37941aed257ce885.snapshot', path = 'C:\Dev\Google\dart-sdk\sdk\pkg\analysis_server\.dart_tool/pub\bin\test\tmp5ae60430\test.dart-3.3.0-edge.6b5b3cc98a23afb58ffdaebf37941aed257ce885.snapshot.incremental.temp' (OS Error: Access is denied.

, errno = 5)

sigurdm avatar Dec 07 '23 13:12 sigurdm

I recently enabled using the VS Code test runner (which goes through dart test) in the SDK which now sometimes triggers this issue.

PathAccessException: Cannot rename file to '..\..\.dart_tool/pub\bin\test\test.dart-3.8.0-edge.82282b6287104d125e82172199a8d6b070102354.snapshot', path = '..\..\.dart_tool/pub\bin\test\tmp41edeca9\test.dart-3.8.0-edge.82282b6287104d125e82172199a8d6b070102354.snapshot.incremental.temp' (OS Error: Access is denied.
, errno = 5)
#0      _File.throwIfError (dart:io/file_impl.dart:782:7)
#1      _File.renameSync (dart:io/file_impl.dart:399:5)
#2      renameFile (package:pub/src/io.dart:565:14)
#3      precompile (package:pub/src/dart.dart:169:7)
<asynchronous suspension>
#4      Entrypoint._precompileExecutable (package:pub/src/entrypoint.dart:743:5)
<asynchronous suspension>
#5      Entrypoint.precompileExecutable.<anonymous closure> (package:pub/src/entrypoint.dart:728:14)
<asynchronous suspension>
#6      Progress.stop (package:pub/src/progress.dart:61:3)
<asynchronous suspension>
#7      Entrypoint.precompileExecutable (package:pub/src/entrypoint.dart:726:5)
<asynchronous suspension>
#8      errorsOnlyUnlessTerminal (package:pub/src/log.dart:435:18)
<asynchronous suspension>
#9      getExecutableForCommand (package:pub/src/executable.dart:426:9)
<asynchronous suspension>
#10     RunCommand.run (package:dartdev/src/commands/run.dart:419:20)
<asynchronous suspension>
#11     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#12     DartdevRunner.runCommand (package:dartdev/dartdev.dart:247:18)
<asynchronous suspension>
#13     runDartdev (package:dartdev/dartdev.dart:47:16)
<asynchronous suspension>
#14     main (file:///C:/b/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart:13:5)
<asynchronous suspension>

My preference would be to not revert this (assuming I can get all of the tests passing through the test runner), but I don't know if this might force it. @sigurdm if this isn't a simple fix, do you know of any possible workarounds that might improve things on Windows?

DanTup avatar Apr 02 '25 15:04 DanTup