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

Don't use :remove_destination option to FileUtils.cp_r #12165

Conversation

justinseanmartin
Copy link
Contributor

@justinseanmartin justinseanmartin commented Nov 25, 2023

The docs for FileUtils.cp_r state:

If remove_destination is true, this method removes each destination file before copy.

This isn't the behavior like rsync --delete provides, where it removes extraneous files. Instead, it seems like this feature was added to Ruby to deal with cases where the file being copied over is potentially actively in use during the copy operation. Instead of overwriting the file, it'll unlink the file first here, which allows open file handles to continue accessing the old file contents.

In any case, the solution is to go back to the previous behavior of doing an rm_rf before the cp_r. Alternatively, we could use rsync --delete here as well, like we did here, but I'd rather minimize the churn.

Without this, the behavior that we were seeing is that we'd end up with an pod install output like:

> Copying PodFramework from /Users/jmartin/Library/Caches/CocoaPods/ios-register/Pods/Release/PodFramework/1.2.3-134c1 to Pods/PodFramework

And we'd end up with the new pods content installed into Pods/PodFramework/1.2.3-134c1 instead of into the root directory. By removing the PodFramework destination directory before the call to cp_r, we will restore the previous expected behavior.

@justinseanmartin justinseanmartin force-pushed the jmartin/no-remove-destination branch 2 times, most recently from 277fff6 to b75a097 Compare November 25, 2023 01:22
@justinseanmartin justinseanmartin merged commit a394a9d into CocoaPods:master Nov 25, 2023
6 checks passed
@justinseanmartin justinseanmartin deleted the jmartin/no-remove-destination branch November 25, 2023 09:04
@Navaie Navaie mentioned this pull request Feb 14, 2024
14 tasks
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

Successfully merging this pull request may close these issues.

None yet

2 participants