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

Remove read-only mark on dist-newstyle when doing cabal clean on Windows #10190

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

jasagredo
Copy link
Collaborator

@jasagredo jasagredo commented Jul 9, 2024

Just one commit, the rest are from the base branch #10255. This still doesn't ensure that the directory can be deleted on the first go, but at least a second cabal clean will for sure clean it.

Closes #10182 #6933

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • Manual QA notes have been included.
  • Tests have been added. (Ask for help if you don’t know how to write them! Ask for an exemption if tests are too complex for too little coverage!)

Depends-On: #10225

QA

Very simple, just doing cabal clean if there is a source-repository-package

❯ cat cabal.project
packages: .

source-repository-package
  type: git
  location: https://github.com/haskell/bytestring

❯ cabal build
Cloning into 'C:\Users\Javier\code\aa\dist-newstyle\src\bytestring-ea6cd2d51c6ca30b'...
...

❯ cabal clean
C:\Users\Javier\code\aa\dist-newstyle\src\bytestring-ea6cd2d51c6ca30b\.git\objects\pack\pack-8793205445310ec514631949079f7ebb57de3771.rev: removeDirectoryRecursive:removeContentsRecursive:removePathRecursive:removeContentsRecursive:removePathRecursive:removeContentsRecursive:removePathRecursive:removeContentsRecursive:removePathRecursive:removeContentsRecursive:removePathRecursive:removeContentsRecursive:removePathRecursive:DeleteFile "\\\\?\\C:\\Users\\Javier\\code\\aa\\dist-newstyle\\src\\bytestring-ea6cd2d51c6ca30b\\.git\\objects\\pack\\pack-8793205445310ec514631949079f7ebb57de3771.rev": permission denied (Access is denied.)

The above will work with this patch.

@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch from 9791f2d to 0dcc394 Compare July 9, 2024 13:56
@jasagredo jasagredo marked this pull request as ready for review July 9, 2024 17:28
@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch from 0dcc394 to b0df28a Compare July 15, 2024 15:45
Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch 2 times, most recently from 8295a0c to 3545f2b Compare July 16, 2024 11:07
@jasagredo jasagredo changed the title Remove path forcibly on cabal clean on Windows Remove read-only mark on dist-newstyle when doing cabal clean on Windows Jul 16, 2024
@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch from 3545f2b to 558ce0f Compare July 16, 2024 11:13
Copy link
Collaborator

@andreabedini andreabedini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I would have never thought deleting files on Windows would be so hard 😂

@geekosaur
Copy link
Collaborator

Are we waiting on something or should the "merge me" label be added now?

@jasagredo
Copy link
Collaborator Author

I wanted to add a test before merging.

@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch from 558ce0f to 599def7 Compare July 22, 2024 21:21
@jasagredo
Copy link
Collaborator Author

Added test, we can merge

@jasagredo jasagredo added the merge me Tell Mergify Bot to merge label Jul 22, 2024
@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch 3 times, most recently from fe5b2cc to 802b743 Compare July 22, 2024 23:16
@jasagredo
Copy link
Collaborator Author

Retrying once doesn't seem to solve the issue. Should I:
a) remove the test, we know this thing is flaky but the fix just makes it sometimes less flaky but not always
b) retry until it succeeds
?

@ulysses4ever
Copy link
Collaborator

This is a driveby opinion. Removing the test would be a pity, so not (a). If there's a slight increase in CI spurious failures with the test enabled (I assume, there is, but just sanity checking), it shouldn't be enabled, so not (b). This leaves me at (c): mark the test as skipped and refer to an issue best positioned to explain the problem.

@jasagredo
Copy link
Collaborator Author

When I say the test I mean the new test that I have introduced, which just gets a source-repository-package and then cleans. It is mainly interesting in Windows, so skipping it is kind of not very interesting.

I wonder if another combinator could be created that specifies that a test is flaky, and accepts it whether it passes or not. If it passes many times hopefully someone will eventually notice that it started passing again and maybe re-enabling it can be done at that point.

Or that it specifies the output also for failing and something that says "sometimes it fails, if it fails with this output the it is ok because it is flake, if it fails with another output then there is a different error going on, if it passes then it's fine"

@jasagredo jasagredo removed the merge me Tell Mergify Bot to merge label Jul 24, 2024
@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch from 802b743 to 28b7570 Compare July 24, 2024 00:10
@jasagredo
Copy link
Collaborator Author

Depends on #10225

@geekosaur
Copy link
Collaborator

FWIW you can put that in the top of the pull request: https://docs.mergify.com/workflow/actions/merge/#pull-request-dependencies

@ulysses4ever
Copy link
Collaborator

FWIW you can put that in the top of the pull request: docs.mergify.com/workflow/actions/merge/#pull-request-dependencies

wow, that rocks!

@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch 2 times, most recently from b642f7a to e4deb94 Compare July 25, 2024 16:17
@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch 4 times, most recently from 33f98d1 to 9de591b Compare July 28, 2024 15:49
@geekosaur
Copy link
Collaborator

Is this still waiting on something?

@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch from 9de591b to 92c1510 Compare August 26, 2024 22:05
@jasagredo jasagredo added the merge me Tell Mergify Bot to merge label Aug 27, 2024
@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch from 92c1510 to 9d9c239 Compare August 27, 2024 21:35
@jasagredo jasagredo removed the merge me Tell Mergify Bot to merge label Aug 27, 2024
@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch 2 times, most recently from ca28ada to f5f7bd7 Compare September 1, 2024 22:08
@jasagredo jasagredo added the merge me Tell Mergify Bot to merge label Sep 1, 2024
@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch from f5f7bd7 to 5c51c12 Compare September 1, 2024 22:16
@mergify mergify bot added ready and waiting Mergify is waiting out the cooldown period merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days labels Sep 1, 2024
@tomsmeding
Copy link
Collaborator

For some reason, perhaps because this package has a custom Setup.hs, cabal build seems to want to reinitialise submodules of source-repository-packages repos very often. Normally this is annoying but not really a problem, but on Windows, due to the issue that this PR addresses, this means that the second cabal build will always fail for this package. If you have built once, you cannot build again -- you have to delete dist-newstyle first, then you can build from scratch, thank you.

Please merge this PR and release it as soon as possible. :)

@geekosaur
Copy link
Collaborator

@jasagredo, GitHub is complaining about conflicts and Mergify is throwing errors trying to correct them?

@ulysses4ever
Copy link
Collaborator

Maybe someone other than the author should manually rebase, if the author is currently busy.

@geekosaur
Copy link
Collaborator

geekosaur commented Sep 10, 2024

I considered doing it myself, but since it's Windows I worry that I'd run into things I wouldn't know how to resolve.

@jasagredo
Copy link
Collaborator Author

I will rebase and merge this PR.

@tomsmeding keep in mind what I mentioned in the description: This is not a silver bullet. Perhaps what was here in the first version was better, namely removeDirectoryForcibly, but that still might fail due to the files being in use 🙄

@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch from 5c51c12 to a9dc5cf Compare September 12, 2024 23:08
@jasagredo
Copy link
Collaborator Author

I implemented a slightly stronger version (remove read-only mark + force delete the directory). Also when dealing with submodules now. @tomsmeding may you try with the cabal from this branch to see if it works better now, or point me to the package that you are having issues with so that I can play with it myself?

@jasagredo jasagredo force-pushed the js/remove-forcibly-windows-clean branch from a9dc5cf to 82d977a Compare September 12, 2024 23:11
Some git files are marked as read-only. To ensure we delete the folders we are
supposed to, we first remove the read-only attribute via `CMD.exe`, then we
forcibly delete the relevant directory.
@mergify mergify bot merged commit efa04f7 into haskell:master Sep 13, 2024
50 checks passed
@tomsmeding
Copy link
Collaborator

@jasagredo No guarantees I'll have time (sorry, have to find a windows machine again), but to increase the chances: is there a cabal windows binary that I can easily download (CI artifacts?) that includes this PR?

@geekosaur
Copy link
Collaborator

@tomsmeding
Copy link
Collaborator

This works beautifully for me! Thanks for fixing (at least for my usecase); looking forward to the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge platform: windows ready and waiting Mergify is waiting out the cooldown period
Projects
None yet
7 participants