Tome not working with Drush 12

Created on 19 July 2023, over 1 year ago
Updated 17 January 2024, 10 months ago

Problem/Motivation

I'm new to drupal and I'm testing Tome to static site generation following this tutorial

https://tome.fyi/docs/installing-existing-site/

Unfortunally tome:static (or other tome:*) command is not loaded by latest drush 12.

And look like drush 9 is not compatible with Drupal 10,

so at the end I'm not able to use Tome with Drupal 10.

Steps to reproduce

Install latest Drupal with demo_umame
$ composer require drupal/tome
$ drush en tome_static -y
$ composer require drush/drush
$ drush tome:static --uri=http://mysite.com

Proposed resolution

Update Tome Commands to make them compatibles with Drush 12

📌 Task
Status

Fixed

Version

1.10

Component

Tome Static

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India Shreya_98

    it will be great if you will update the drush version then you will not get this issue.

  • 🇨🇦Canada joseph.olstad

    composer why drush/drush;
    ?? why

    composer up drush/drush -W
    
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Shreya_98

    @joseph.olstad Drupal 10 supports drush 12

  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • To get Drupal 10 and Drush 12 to work, I needed to add this patch for the drupal-tome/tome_drush package and apply this patch that adds a drush.services.yml file to the tome_static and tome_sync sub-modules. However, support for the drush.services.yml file will be removed in Drush 13 according to Drush 12's documentation:

    Drush 11 and prior required dependency injection via a drush.services.yml file. This approach is deprecated in Drush 12 and will be removed in Drush 13.

  • Status changed to RTBC over 1 year ago
  • 🇩🇪Germany gnuschichten

    I applied the tome_drush12-support.patch and drush "tome" is now a defined namespace. I have successfully tested the following commands: drush tome:static and drush tome:export

    Tested with Drupal 10.1.2 and Drush 12.1.3

  • 🇧🇪Belgium dieterholvoet Brussels

    If you're okay with only supporting Drush 12, you can change the Commands namespace to Drush\Commands and you won't need the drush.services.yml file. That would mean dropping support for Drupal versions below 10 though.

  • 🇺🇸United States greg.1.anderson

    Regarding #9 above, the new Command mechanisms from Drush 12 were backported to the most recent versions of Drush 11, so you can go ahead and adopt the new recommended static Create method, and your code will still be able to work on Drupal 9.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States samuel.mortenson

    Thanks for the work all - putting back to "Needs work" for two reasons:

    1. Drush versions prior to 12 allowed Symfony commands defined as services to be executed. This isn't a Drupal 10 issue or a Tome issue (subjectively, I had been told that this had worked in Slack but it's undocumented), it's a Drush 12 issue. If we can figure out the issue with Drush 12 and make a PR to the Drush repo that would be preferable.

    2. If (1) isn't possible, we can do #10, but that feels like a breaking change to me. I don't want to make a new branch/minor and also don't feel like adding Drush as a composer dependency is appropriate. Need to think about this more.

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
  • @jeremypeter When you incorporate this patch into the composer.json file, where should it go exactly? Thus far, I've applied the patch, "tome_drush12-support.patch".

  • @frankangelone Along with adding the patch, add the following to the repositories array/object in your composer.json:

    {
        "type": "vcs",
        "url": "https://github.com/elgandoz/tome_drush.git"
    }
    

    Then in your require object, update the drupal-tome/tome_drush package to:

    "drupal-tome/tome_drush": "dev-dev-drush12"
    
  • @jeremypeter Thank you for the instructions. I manually added both code blocks as you described. However, I'm still seeing the error, "There are no commands defined in the "tome" namespace."

    My order of operations were as follows:
    1. Install Drush: composer require drush/drush
    2. Apply patch: curl https://www.drupal.org/files/issues/2023-08-02/tome_drush12-support.patch | git apply --index -
    3. Manually add the two code blocks you shared with me

    I am wondering if any of the code blocks I manually added were intended to be added via composer? (i.e. composer require drupal-tome/tome_drush and then append "dev-dev-drush12" manually)

  • @frankangelone here's an example gist of a composer.json file that has these changes. It installs the patch by leveraging the cweagans/composer-patches package which allows you to install patches via composer the extra.patches object.

  • @jeremypeter That fixed it! After I ran composer require cweagans/composer-patches, manually applied the patches block from the example gist, and ran composer update, I could run Drush 12 successfully. Thank you for your help. When there's an official fix for Drush 12, I'm guessing we'll have to remove the patch before applying the official update. Is that correct?

  • 🇺🇸United States DTWtoMSY

    I've followed this thread's advice but ended up with an error. "Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2023-08-02/tome_drush12-support.patch "

    Does anyone have any help they can offer?

  • @DTWtoMSY When I applied the patch I was in the root directory of my project. I then used the instructions I found from Drupal documentation to apply the patch. The option I used was step 2 from comment #15 📌 Tome not working with Drush 12 Needs work . I'm guessing you probably attempted this already from your comment. I stumbled across this issue thread regarding the error message. It's tied to the same cweagans/composer-patches package. Do you have this package in your composer.json file?

  • 🇧🇪Belgium dieterholvoet Brussels

    If (1) isn't possible, we can do #10, but that feels like a breaking change to me. I don't want to make a new branch/minor and also don't feel like adding Drush as a composer dependency is appropriate. Need to think about this more.

    I don't think that's a breaking change. Only the actual commands should be considered part of the public API, not the command files or the service definitions. Instead of adding Drush as dependency, you could add the following:

    {
      "conflict": {
        "drush/drush": "<11.6"
      }
    }
    
  • 🇺🇸United States DTWtoMSY

    @frankangelone THANK YOU!!! I was using cmd.exe. I switched to git bash and it installed no problem.

  • @DTWtoMSY I'm glad to hear you were able to get it working!

    • jeremypeter authored 78166fbd on 8.x-1.x
      Issue #3375608 by jeremypeter, frankangelone, fabiano.vista, Shreya_th,...
  • Status changed to Fixed 12 months ago
  • 🇺🇸United States samuel.mortenson

    Sorry for the delay and thanks all - I've applied the patch in #7 in addition to doing a few other minor fixes. Should release later today.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 10 months ago
  • 🇬🇧United Kingdom joachim

    I'm not sure we needed to add the conflict with Drush < 11.6 in composer.json, as the Drush 11.5.1 docs at https://www.drush.org/11.5.1/dependency-injection/ say :

    > Drush command files can request that Drupal inject services by using a drush.services.yml file.

Production build 0.71.5 2024