I recently updated to drupal core https://www.drupal.org/project/drupal/releases/11.4.0 afterwards drush deploy always Fails with the following message:

ddev drush deploy
Notice: ] Database updates start.
> 
> In DefinitionErrorExceptionPass.php line 48:
>                                                                                
>   Cannot autowire service "Drupal\twig_tweak\Command\DebugFunctionsCommand":   
>   argument "$twig" of method "__construct()" references class "Twig\Environme  
>   nt" but no such service exists. You should maybe alias this class to the ex  
>   isting "twig" service.                                                       
>                                                                                
> 

In SiteProcess.php line 214:
                                                                               
  The command "/var/www/html/app/vendor/bin/drush updatedb failed.                                                        
                                                                               
  Exit Code: 1(General error)                                                  
                                                                               
  Working directory:                                                           
                                                                               
  Output:                                                                      
  ================                                                             
                                                                               
                                                                               
  Error Output:                                                                
  ================                                                             
                                                                               
  In DefinitionErrorExceptionPass.php line 48:                                 
                                                                               
                                                                               
    Cannot autowire service "Drupal\twig_tweak\Command\DebugFunctionsCommand":                                                                            
    argument "$twig" of method "__construct()" references class "Twig\Environment" but
    no such service exists. You should maybe alias this class to  the existing "twig" service.                                                     
                                                                               

From what i gathered this seems to be a conflict between declaring a drush command and the dr cli tool introduced in 11.4 https://www.drupal.org/node/3584928, though i am not certain about that.

CommentFileSizeAuthor
#4 3607930-autowire-twig-environment-4.patch310 byteskala4ek

Issue fork twig_tweak-3607930

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

johannes.heinzerling created an issue. See original summary.

m@ster’s picture

twig_tweak 4.0.0-alpha2's debug commands use #[AsCommand] attribute, causing Drupal to autowire them. But Twig\Environment is registered as the twig service (not by class), and SignatureFormatter isn't registered at all.

kala4ek’s picture

Status: Active » Needs review
StatusFileSize
new310 bytes

Faced the same. That patch helped me.

anybody made their first commit to this issue’s fork.

anybody’s picture

Assigned: Unassigned » grevil

Thanks, I created a MR from #4 - please review.

Can confirm the issue with Drupal 11.4

anybody’s picture

Issue tags: +Needs tests

Any ideas why the tests didn't fail without this fix? I had the issue right after enabling twig_tweak 3.0.0-alpha2

grevil’s picture

Any ideas why the tests didn't fail without this fix

Because gitlab-ci is still using 11.3, but we can activate next minor testing.

grevil’s picture

Hm it is actually activated, but for some reason it was skipped...

anybody’s picture

Assigned: grevil » Unassigned
Status: Needs review » Reviewed & tested by the community

@grevil indeed currently it seems these have to be triggered manually (at the build step).

Let's merge this and tag a new 4.0.0-alpha3 release.

anybody’s picture

(Once pipeline is green)

grevil’s picture

Allowing minor phpunit failure for now, as the test strings are way too specific.

grevil’s picture

Version: 4.0.0-alpha2 » 4.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs tests

Thanks everyone! Merged!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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