Avoid raceconditions in global activate
, run
and global run
#3285
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attempts to fix: #3165
This is done by:
global activate
:Activating a global package into a temp-dir and renaming the dir into the right place.
Two concurrent activations of the same package
foo
will not be able to both contribute to the resulting files, an observer will always see the result of one or the other or none in$PUB_CACHE/global_packages/foo
.Creating binstubs in a temp-dir, making them executable and then moving them into the right place.
It won't be possible to observe half a binstub, or for chmod to have the binstub removed before it can operate on it.
run
/global run
:We already did a copy to preserve the incremental data, the change is to do the copy before compilation not after.
All of this builds on renaming being an atomic operation, another process will either see the old file or the new, never anything in-between.
There is still a possibility of confusing results if you concurrently
dart pub global activate
two different packages with overlapping binstub-names, then you can end up with any possible mixture of these binstubs - don't do that.The pr contains quite some refactoring to allow global packages to exist in a temporary directory.
Also I took out support for pre dart-1.6 style lockfiles.
This fixes: #1111