Score:0

Applying a patch - how?

cn flag

Im trying to install Radix on Drupal 9 (Drush 10) - Installation keeps failing in composer / drush en radix and I have tracked it down to a current "bug" (or atleast a closed bug now) which someone wrote a patch for (#12) - I feel daft but how do one apply this patch?

I read somewhere on another post that I need to add this to my composer.json, but I am not sure to which section or required syntax. Sorry I cannot be more helpful with more information but hoping someone in the community can assist?

leymannx avatar
ne flag
Depending on the exact bug you get either the most upvoted or one of the other answers in the linked question will help you.
tz flag
composer.json based patches also here https://drupal.stackexchange.com/questions/219649/how-to-manage-patches-in-composer-when-theyre-merged-into-the-module but probably leymannx link above has more details
leymannx avatar
ne flag
Okay, so I learned from @anonymous know that we need more context: How exactly do you try to install Radix, the Composer commands, the Drush commands, the host OS, and what exact errors you get? Sounds like you are not familiar with Composer at all, or you are not even using it at all. So please provide more information and update your question. Thank you
Score:-3
fr flag

It's super easy - you don't need to go through composer or anything like that (although if you maintain a website and need a lot of patches to keep it working, it's useful to learn how to use composer in the long run).

Here's how you do it:

Go to the directory where the 'radix' module is installed. Relative to web root, this should be something like /modules/radix or /modules/contrib/radix. Download the patch into that directory - for example, you can use wget https://www.drupal.org/files/issues/2022-01-11/3173811.patch or you can use ftp or any other method you like.

Then, in the same directory where you download the patch, use the command patch -p1 < 3173811.patch.

This assumes you are using a variety of Unix for your website - these commands are available on most distributions. If you are on Windows, you can also find these exact commands but you might have to install the commands yourself.

If that is still too big a barrier, for this patch at least, fixing the code manually is always an option. The patch just corrects two "use" statements:

-use Robo\Task\Archive\loadTasks as ArchiveTaskLoader;
-use Robo\Task\Filesystem\loadTasks as FilesystemTaskLoader;
+use Robo\Task\Archive\Tasks as ArchiveTaskLoader;
+use Robo\Task\Filesystem\Tasks as FilesystemTaskLoader;

The patch is saying that the first two lines need to be deleted (that's what the minus sign means) and the second two lines need to be added in the same place (that's what the plus sign means). The format of the patch uses the first column to show you what to change - if there is nothing in the first column, the line doesn't get changed. If there is a - in the first column, the line gets deleted. If there is a + in the first column, the line gets added. That first column is only used in the patch, it should not appear in the code either before or after you change it.

leymannx avatar
ne flag
OP is using Composer why would you recommend them applying the patch manually?
leymannx avatar
ne flag
It will be gone after the next composer install.
fr flag
No, OP is NOT using Composer - you are missing context - the OP asked this question on Slack and kept getting "composer" as the answer. The fact that the OP had to come here a day later to ask the same question means that the advice on Slack about "composer" didn't help. Clearly, that is not a responsive answer. Telling someone that has not installed everything via composer to use Composer to install patches is just throwing up barriers rather than trying to solve problems.
fr flag
I was also clear that Composer is a good solution for the long-term, but the OP's problem is way more fundamental than that - the OP does not understand the basics of how to apply a patch. Assuming that everyone is a developer and that everyone is a Composer expert is one of the basic flaws of Drupal support. Perhaps try to approach this from the point of view of someone who is not a full-time developer and who just wants to get something working ...
leymannx avatar
ne flag
Yes, we've not been on Slack with that user. All we see is "trying to install something with Composer" but failing (no errors given), and "I need this patch in composer.json, but I don't know the required syntax". This is the context we have, and for that your answer seems wrong. No offense! I'm glad I learned more context about the question now. Thank you
cn flag
@anonymous Please remember the site isn’t here for one to one support, it’s here to create long lasting reference material. All context needed to answer a question is in the question body, by definition - if it isn’t, it gets extracted from the user in comments. and then added to the question, so it can make sense to future visitors. Right now, all visitors can see is a question asking how to apply a patch using composer, and an answer giving details on how to do it in several other ways, but not the way asked. I appreciate you have extra context and of course it’s great that you’re trying…
cn flag
…to help the OP out, but to do that here, you’ll need to get the external context into the question, or the answer simply won’t make sense. If that needs a bit of a collaboration with the OP to change the question so it matches what they really meant to ask then that’s fine, but the end result needs to be that the answer addresses the stated question, for what are hopefully obvious reasons in a Q+A site :)
fr flag
The question is "how to apply a patch" and my answer is perfectly valid and useful and responsive to that, as well as of general use. Three of you have downvoted it, which means you have assumed a context for the question, namely the skill set and workflow that the OP uses. Regardless, you're telling a non-developer to "patch" composer.json by hand-editing a composer.json just in order to apply a "patch" to a module. My answer above is far more useful to *most* Drupal users.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.