-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
Patched projects will be deleted and re-downloaded and patched #42
Comments
Isn't something like
|
Hm, composer-preserve-paths should take care of this, but evidently, it's not. I'll take a look. |
I'm also encountering this issue, downgrading to 1.3.0 of composer-patches doesn't help, neither does explicitly declaring the core root path under preserve-paths. |
Was this ever working (in any version of this plugin)? It's possible that it had never worked. |
I don't know for sure. I encountered this behavior recently when I tried to use the plugin on a D7 project for the first time. I was only using it on D8 previously. Le 25 avril 2016 18:45:16 CEST, Cameron Eagans notifications@github.com a écrit :
Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté. |
It seems none of the events composer-preserve-paths is subscribed to trigger when composer-patches does I have seen some deprecation notices in Composer/Composer regarding these events. Wonder if that has anything to do with it. I will follow up next weekend. |
Here is the link to issue - drupal-composer/preserve-paths#10 |
I think this use-case was never anticipated. Shouldn't the event dispatcher be called before My hypothesis is composer-preserve-paths will back everything up when PRE_PACKAGE_UNINSTALL fires before the uninstall operation in this plugin. Then when the package is installed again, it will be patched because of the implicit trigger of POST_PACKAGE_INSTALL. Also composer-preserve-paths will restore the configured preserved paths. Does anyone have any usefull feedback on this before diving into the IDE? |
Just clicking through some of the Composer files on Github -- I didn't see anywhere that PRE_PACKAGE_UNINSTALL would have been dispatched. It's entirely possible that simply dispatching that event before |
(And for the record, I was aware of composer-preserve-paths -- I just figured that calling |
I understand. Would make sense from a semantic standpoint that I use composer-preserve-paths for Drupal 7 as 3rd party packages are stored inside the root package. I don't like this, but it seems necessary if you don't want to symlink your packages into the root package. I am going to look into this and create a PR if I can get it to work. This would not only benifit composer-preserve-paths, but all composer plugins which hook in to the event bus. I did see the event dispatcher needs a lot of arguments, so no quick fix today. |
This might be a duplicate of #26 and I've submitted a PR there as well. |
@piepkrak Have you made any progress with this? Looking into the problem, I basically came to the same conclusion (it's funny how an issues can look like total gibberish until you've actually done some of the troubleshooting yourself, after which it makes perfect sense :)). I was not quite sure how to fill the various inputs the event dispatcher needs to dispatch a package event, though. |
Unfortunately not. Dispatching the event was also the blocker for me at the time. Will try to free up some time next week. |
Related question composer/composer#6261 |
I tried dispatching the event but it is very ugly, but usable, see SebCorbin@1cb9bac |
Is there something that we can do in this plugin (other than manually dispatching the event) that would cause that line to be run? I haven't stepped through this too much, as this has been fairly low priority for me. |
For the moment, no: either we ask the composer team to dispatch the event on |
Why not add a PR from SebCorbin@1cb9bac for the time being. We still face this with Drupal 7 projects on core patched and upgrade/downgrades of core. |
I've asked @SebCorbin to create a PR of that commit into this project. I think it makes sense to explicitly fire those events in composer-patches, if composer doesn't do that implicitly. |
For now, added the fix to the 7.x branch of https://github.com/drupal-composer/drupal-project/tree/7.x |
@cweagans It seems that @SebCorbin is not going to create the PR. Would you consider merging SebCorbin@1cb9bac anyway? |
I'm not sure. I don't really want to just blindly merge it because even though it solves the problems with composer-preserve-paths, it might have unintended effects on other plugins that are listening for those events because that change dispatches the events with empty data. I don't know that we can do much of anything else, but I think it's worth some investigation before merging at least. To my knowledge, that investigation has not been done. |
Thoughts on drupal-composer/preserve-paths#10 (comment)? |
Replicating the `\Composer\Installer::doInstall` logic. Refs cweagans#42
Replicating the `\Composer\Installer::doInstall` logic. Refs cweagans#42
@cweagans Would there be a way to force composer-patches to patch itself in a post-create-project-cmd step? Or would you be willing to add a pre-2.x patch if we modify the code in this commit to only be active if we set a flag on the composer.json config? |
Also note that if composer-exit-on-patch-failure is set true, the code should try to cleanup before exiting by calling the POST_PACKAGE_UNINSTALL event. That way stuff doesn't get stuck in the preserve-paths limbo at ~/.cache/composer/preserve-paths. |
Created PR #257 |
This seems to be made worse in composer 2. I'm seeing patches fail to apply on the first run. Seemingly the entire web root for Drupal 7 is lost or does not exist before patches apply (or is not actually installed yet...) I do notice in composer v2 the patches aren't applying in order. They apply all at the end. I am wondering too if this occurs before the installations is done for drupal/core thus no files exist yet. Running composer install a second time seems to work. |
@jcnventura I applied the latest commit from 9 days ago and the web directory gets deleted if I use composer 2, seems to work ok with composer 1. For some reason with composer 2 it doesn't seem like composer-patches ever gets patched, didn't try to find out why, I'll stick to composer 1 for now |
Trying to move a D7 site to use Composer 2 results in failure because the preserve-paths options are ignored, resulting in huge amounts of the codebase being deleted, even with the patch. As a newcomer to Composer with D7 this is quite the nasty surprise, so no more Composer on my D7 projects, back to Drush Make it is. |
Same here. I would recommend not to use Drupal 7 with composer and preserve-paths until the bug is fixed. |
And yes, lost the entire web directory. |
I had to revert drupal-composer/drupal-project@b9541d3 to preserve paths (Composer 2). |
I think in composer 2 the empty params no longer are used so it is purely the local repository given and the operations, and this should be sufficient. An opt-in flag would be useful, changing to opt-out if it works, and then removing the flag if no issues. This is how composer itself implements potential breaking changes. |
|
Closing for now, but let me know if we need to re-open. |
@cweagans Just FYI I raised drupal-composer/preserve-paths#42 as I found that actually this behaviour can be also caused by preserve-paths. There’s reproduction there too. @steinmb i would suggest preserving individual theme and module folders within web/sites/ and not the entire tree and try that. It’s likely in preserving web/sites you will hit issue where a meta package is encountered and web/sites gets backed up again with a partially extracted core that doesn’t contain your modules. Essentially you need ensure what you preserve does not exist after any package installations or you risk a second backup of it without your data. So preserve things like web/sites/all/modules/custom/TEST and individual files instead of the whole tree. Granted, this won’t work for overrides I’m afraid. Essentially for cases where the composer patches uninstall patch fails it’s an issue with preserve paths |
I edited comment to clarify - there’s two issues so the one I note is a new one but this uninstall issue is still a thing. Tho maybe not in the new main branch! |
This causes issues when drupal/drupal (version 7) is patched as everything resides in whatever location Drupal has been installed in.
As far as I know it is not possible to run Drupal itself as a dependency, so we would need something like https://github.com/winmillwill/drupal-tangler to resolve this issue. Do you have any other working solutions to this issue?
The text was updated successfully, but these errors were encountered: