-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
pants package ::
can corrupt directory target output by leaving stale/deleted contents
#18849
Comments
@huonw its quibbling, but Pants has always just populated |
Feel free to reframe it as a feature request (although, from a user perspective, the end result of silently corrupting a target-that-outputs-a-directory is very surprising, and is very different to target-that-outputs-a-file). |
Ah, I read too fast. Ok, yeah - not removing the complete dir then replacing it is odd. Pex used alone does that; so Pants is doing something weird here. |
pants package ::
can leave stale/deleted contents in directory targetspants package ::
can corrupt directory target output by leaving stale/deleted contents
This applies a workaround that fixes #18809, for 2.16: before this PR, repeated commands that write the exact same contents to `dist/` will fail, if those contents include a symlink. After this patch, they will succeed. For instance, `pants export-codegen ::` twice if any codegen creates a symlink. The particular problem of failing when re-materialising an entry only surfaces with symlinks, because directories are created in "exists okay" mode, and files are truncated if they already exist. However, directories and files _do_ have problems when being materialised over an entry of a different kind (#17758), but fixing that seems like a broader issue, and likely too large to target 2.16 at this point. After the change in this PR, we're at least back to the behaviour in 2.15: - directly rerunning commands that write to the workspace will always succeed - rerunning after changes may or may not (and, if it does, may or may not give a valid result: #18849) I've started on a potential fix for #17758 and #18849 in #18871, but, as mentioned, it felt like it was getting too large and too "feature"-y to land for 2.16. If/when a fix along those lines lands, this workaround can likely be reverted.
…8873) This applies a workaround that fixes pantsbuild#18809, for 2.16: before this PR, repeated commands that write the exact same contents to `dist/` will fail, if those contents include a symlink. After this patch, they will succeed. For instance, `pants export-codegen ::` twice if any codegen creates a symlink. The particular problem of failing when re-materialising an entry only surfaces with symlinks, because directories are created in "exists okay" mode, and files are truncated if they already exist. However, directories and files _do_ have problems when being materialised over an entry of a different kind (pantsbuild#17758), but fixing that seems like a broader issue, and likely too large to target 2.16 at this point. After the change in this PR, we're at least back to the behaviour in 2.15: - directly rerunning commands that write to the workspace will always succeed - rerunning after changes may or may not (and, if it does, may or may not give a valid result: pantsbuild#18849) I've started on a potential fix for pantsbuild#17758 and pantsbuild#18849 in pantsbuild#18871, but, as mentioned, it felt like it was getting too large and too "feature"-y to land for 2.16. If/when a fix along those lines lands, this workaround can likely be reverted.
#18873) (#18878) This applies a workaround that fixes #18809, for 2.16: before this PR, repeated commands that write the exact same contents to `dist/` will fail, if those contents include a symlink. After this patch, they will succeed. For instance, `pants export-codegen ::` twice if any codegen creates a symlink. The particular problem of failing when re-materialising an entry only surfaces with symlinks, because directories are created in "exists okay" mode, and files are truncated if they already exist. However, directories and files _do_ have problems when being materialised over an entry of a different kind (#17758), but fixing that seems like a broader issue, and likely too large to target 2.16 at this point. After the change in this PR, we're at least back to the behaviour in 2.15: - directly rerunning commands that write to the workspace will always succeed - rerunning after changes may or may not (and, if it does, may or may not give a valid result: #18849) I've started on a potential fix for #17758 and #18849 in #18871, but, as mentioned, it felt like it was getting too large and too "feature"-y to land for 2.16. If/when a fix along those lines lands, this workaround can likely be reverted.
Describe the bug
A packageable target can sometimes be a directory. For instance,
pex_binary(..., layout="packed")
(orlayout="loose"
). If someone has runpants package ::
once to output this target, makes a change that removes files, and then rerunspants package ::
, the removed files are left there.In theory, writing to
dist/
should exactly synchronise the contents of a target-that-outputs-directory (removing stale contents). This will need to be done at an appropriate level, e.g. for a packed pexpants package path/to:target
, it'll outputdist/path.to/target.pex/...
, but it should only synchronisedist/path.to/target.pex/
, not removing anything fromdist/
ordist/path.to/
.This likely applies to other methods of writing to
dist/
, likeexport-codegen
.Reproducer:
Output:
initial export
BUG: b.py is still in dist/pex.pex/
clear out and start again ...
Pants version
2.15.0
OS
macOS
Additional info
Potentially vaguely related: #17758, #18809.
The text was updated successfully, but these errors were encountered: