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

Can't upgrade 2.8.1 packages to 2.9.0 #907

Closed
adrolter opened this issue May 27, 2023 · 20 comments · Fixed by #911
Closed

Can't upgrade 2.8.1 packages to 2.9.0 #907

adrolter opened this issue May 27, 2023 · 20 comments · Fixed by #911

Comments

@adrolter
Copy link

I'm not sure if the issue is with my setup, the new symfony/stimulus-bundle, or UX, but my service container won't build with any UX 2.9.0 packages installed. I can explicitly require symfony/stimulus-bundle 2.9.0 with UX 2.8.1 packages and all is fine, but upgrading UX packages results in service resolution errors.

composer.json:

image

Running a composer update results in:

  Gathering patches from patch file.
  Loading composer repositories with package information
  Restricting packages listed in "symfony/symfony" to "^6"
  Updating dependencies
  Lock file operations: 1 install, 6 updates, 0 removals
    - Upgrading symfony/flex (v2.3.0 => v2.3.1)
    - Locking symfony/stimulus-bundle (v2.9.0)
    - Upgrading symfony/ux-chartjs (v2.8.1 => v2.9.0)
    - Upgrading symfony/ux-dropzone (v2.8.1 => v2.9.0)
    - Upgrading symfony/ux-live-component (v2.8.1 => v2.9.0)
    - Upgrading symfony/ux-notify (v2.8.1 => v2.9.0)
    - Upgrading symfony/ux-turbo (v2.8.1 => v2.9.0)
  Writing lock file
  Installing dependencies from lock file (including require-dev)
  Package operations: 1 install, 6 updates, 0 removals
    - Downloading symfony/flex (v2.3.1)
    - Downloading symfony/stimulus-bundle (v2.9.0)
    - Downloading symfony/ux-chartjs (v2.9.0)
    - Downloading symfony/ux-dropzone (v2.9.0)
    - Downloading symfony/ux-live-component (v2.9.0)
    - Downloading symfony/ux-notify (v2.9.0)
    - Downloading symfony/ux-turbo (v2.9.0)
  Gathering patches from patch file.
  Gathering patches for dependencies. This might take a minute.
    - Upgrading symfony/flex (v2.3.0 => v2.3.1): Extracting archive
    - Installing symfony/stimulus-bundle (v2.9.0): Extracting archive
    - Upgrading symfony/ux-chartjs (v2.8.1 => v2.9.0): Extracting archive
    - Upgrading symfony/ux-dropzone (v2.8.1 => v2.9.0): Extracting archive
    - Upgrading symfony/ux-live-component (v2.8.1 => v2.9.0): Extracting archive
    - Upgrading symfony/ux-notify (v2.8.1 => v2.9.0): Extracting archive
    - Upgrading symfony/ux-turbo (v2.8.1 => v2.9.0): Extracting archive
  Package fgrosse/phpasn1 is abandoned, you should avoid using it. No replacement was suggested.
  Package php-http/message-factory is abandoned, you should avoid using it. Use psr/http-factory instead.
  Generating optimized autoload files
  157 packages you are using are looking for funding.
  Use the `composer fund` command to find out more!
  Endroid Installer detected project type "symfony"
  
  What about running composer global require symfony/thanks && composer thanks now?
  This will spread some 💖  by sending a ★  to the GitHub repositories of your fellow package maintainers.
  
  Run composer recipes at any time to see the status of your Symfony recipes.
  
  Executing script cache:clear [KO]
   [KO]
  Script cache:clear returned with error code 255
  !!  Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException {#16135
- !!    #message: "The service "chartjs.twig_extension" has a dependency on a non-existent service "stimulus.helper"."
  !!    #code: 0
  !!    #file: "/data/app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php"
  !!    #line: 83
  !!    -id: "stimulus.helper"
  !!    -sourceId: "chartjs.twig_extension"
  !!    -alternatives: []
  !!    trace: {
  !!      /data/app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:83 { …}
  !!      /data/app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:80 { …}
  !!      /data/app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:46 { …}
  !!      /data/app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:89 { …}
  !!      /data/app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:46 { …}
  !!      /data/app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:80 { …}
  !!      /data/app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:46 { …}
  !!      /data/app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:44 { …}
  !!      /data/app/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:37 { …}
  !!      /data/app/vendor/symfony/dependency-injection/Compiler/Compiler.php:73 { …}
  !!      /data/app/vendor/symfony/dependency-injection/ContainerBuilder.php:721 { …}
  !!      /data/app/vendor/symfony/http-kernel/Kernel.php:499 { …}
  !!      /data/app/vendor/symfony/http-kernel/Kernel.php:721 { …}
  !!      /data/app/vendor/symfony/http-kernel/Kernel.php:123 { …}
  !!      ./src/App/Kernel.php:66 {
  !!        Moyer\App\Kernel->boot(): void
  !!        › {
  !!        ›     parent::boot();
  !!        › 
  !!      }
  !!      ./bin/console:44 { …}
  !!    }
  !!  }
  !!  2023-05-27T19:09:41+00:00 [critical] Uncaught Exception: The service "chartjs.twig_extension" has a dependency on a non-existent service "stimulus.helper".
  !!  
  Script @auto-scripts was called via post-update-cmd

Whereas this configuration works:

image

  Gathering patches from patch file.
  Loading composer repositories with package information
  Restricting packages listed in "symfony/symfony" to "^6"
  Updating dependencies
  Lock file operations: 1 install, 1 update, 0 removals
    - Upgrading symfony/flex (v2.3.0 => v2.3.1)
    - Locking symfony/stimulus-bundle (v2.9.0)
  Writing lock file
  Installing dependencies from lock file (including require-dev)
  Package operations: 0 installs, 1 update, 0 removals
  Gathering patches from patch file.
  Gathering patches for dependencies. This might take a minute.
    - Upgrading symfony/flex (v2.3.0 => v2.3.1): Extracting archive
  Package fgrosse/phpasn1 is abandoned, you should avoid using it. No replacement was suggested.
  Package php-http/message-factory is abandoned, you should avoid using it. Use psr/http-factory instead.
  Generating optimized autoload files
  157 packages you are using are looking for funding.
  Use the `composer fund` command to find out more!
  Endroid Installer detected project type "symfony"
  
  What about running composer global require symfony/thanks && composer thanks now?
  This will spread some 💖  by sending a ★  to the GitHub repositories of your fellow package maintainers.
  
  Run composer recipes at any time to see the status of your Symfony recipes.
  
+ Executing script cache:clear [OK]
  Executing script assets:install public [OK]
  
  No security vulnerability advisories found
@alexoueb
Copy link

I have the same error.

@adrolter adrolter changed the title Can't upgrade 2.8.1 packges to 2.9.0 Can't upgrade 2.8.1 packages to 2.9.0 May 27, 2023
@weaverryan
Copy link
Member

Hmm. That’s super weird, that service comes from stimulus bundle. It looks like the StimulusBundle recipe isn’t running, so (and please confirm), the bundle isn’t being registered in bundles.php. Does that look correct? Is symfony.lock updated?

if you do another composer update, does the recipe install? I noticed a bug recently where flex seems to skip recipe installs if flex is also upgraded at the same time. To test, you could go back to your original state, use symfony/flex only and then upgrade everything else. Does it work then?

For others, I think a workaround would be to run:

composer recipes:install symfony/stimulus- bundle --force

after you get this error. If… my guesses are correct :).

@alexoueb
Copy link

My composer update :

  • Installing symfony/stimulus-bundle (v2.9.0)
  • Upgrading symfony/ux-chartjs (v2.8.1 => v2.9.0)
  • Upgrading symfony/ux-live-component (v2.8.1 => v2.9.0)

@weaverryan Symfony\UX\StimulusBundle\StimulusBundle is missing in bundles.php, symfony.lock isn't updated.

I have tried "composer recipes:install symfony/stimulus-bundle --force" with this result: Skipping recipe for symfony/stimulus-bundle: all versions of the recipe conflict with your package versions.

I have tried to add the Bundle manually, but I have another error when i do another composer update : The service "twig" has a dependency on a non-existent service "webpack_encore.twig_stimulus_extension". Did you mean this: "webpack_encore.twig_entry_files_extension"?

I will try other things during the week.

@weaverryan
Copy link
Member

Thanks for the info! I’m also still wondering about this part:

I noticed a bug recently where flex seems to skip recipe installs if flex is also upgraded at the same time. To test, you could go back to your original state, use symfony/flex only and then upgrade everything else. Does it work then?

I’ll also check things out when I’m back at my house later today :).

@gnito-org
Copy link

My experience mirrors #907 (comment).

@gnito-org
Copy link

gnito-org commented May 28, 2023

There's a bigger issue.

I'm running Symfony 6.2 and I'm trying to upgrade my prod system to Symfony 6.2.11.

Stimulus-bundle is marked as experimental.

Why are we even talking about it in Symfony 6.2.11?

I don't want to include an experimental bundle in my prod system.

In terms of UX, composer.json has only "symfony/ux-chartjs": "^2.0". The 6.2.11 upgrade upgraded ux-chartjs to v2.9.0 and that causes the problem. If composer.json is set to "symfony/ux-chartjs": "2.8.*" then the issue disappears.

@gnito-org
Copy link

Perhaps this raises an even bigger question.

Shouldn't all components and bundles that are published by the Symfony organization be consistently versioned, meaning all should comply with the 5.4, 6.2, 6.3, etc., versioning.

That way there will not be a v2.9 bundle that breaks a v6.2.x-dependent production system. It sounds as if stimulus-bundle should really be v6.3 or v6.4.

@xorgxx
Copy link

xorgxx commented May 28, 2023

Hi i juste have try to update form 2.8 to 2.9 and i get

The service "notify.twig_runtime" has a dependency on a non-existent service "stimulus.helper". 

so i go back on 2.8 all back to normal.

129 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
  - Skipping recipe for symfony/stimulus-bundle: all versions of the recipe conf
lict with your package versions.

thank

@weaverryan
Copy link
Member

weaverryan commented May 29, 2023

Hi everyone!

A LOT of moving pieces over the past few days and I missed a few items. Thanks for the detailed reporting :).

tl;dr How do I fix this?

After upgrading, just run composer update one more time.

Note: this will work AFTER symfony/recipes#1203 is merged. If it's not merged yet, you can manually add StimulusBundle to config/bundles.php and THEN run composer update again.

+    Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],

What's actually going wrong?

Oh, it's kind of fun :).

A) The new StimulusBundle recipe (via a conflict in the recipe) requires WebpackEncoreBundle 2.0, as those 2 recipes work together. So if you have WebpackEncoreBundle v1, StimulusBundle's recipe won't install. That's by design!

B) Buuut, instead of Flex creating an "auto-generated" recipe where it at least adds StimulusBundle to config/bundles.php, it does nothing... and the bundle is never added... and you get the error. symfony/recipes#1203 fixes that with a bit of a trick. My bad for note noticing this during testing.

C) But why do we need to run composer update 2 times? When you run composer update the first time, it upgrades a bunch of packages including symfony/flex, because we released a new version a few days ago to support the new StimulusBundle & AssetMapper recipes. It appears that there's a bug where IF you install a new package (e.g. StimulusBundle) AND symfony/flex is being upgraded at the same time, then Flex completely skips installing new recipes. I'm digging into this and hopefully we can fix it. But the 2nd composer update triggers Flex to notice the recipe it missed for StimulusBundle and install it.

UPDATE: Here's the fix for the Flex update problem - symfony/flex#978 - but it won't help users upgrading UX. You will need to run composer update twice as described above.

StimulusBundle experimental?

From @gnito-org above:

I'm running Symfony 6.2 and I'm trying to upgrade my prod system to Symfony 6.2.11.
Stimulus-bundle is marked as experimental.
Why are we even talking about it in Symfony 6.2.11?

You're right - StimulusBundle is not really experimental and shouldn't be listed this way. I've addressed this in #908. Some of the UX packages previously relied on WebpackEncoreBundle to do some internal things. In 2.9, those internal parts now rely in the same functionality, but from StimulusBundle.

Again, thanks everyone for reporting and your patience. There were a lot of things that needed to happen at the same time to add support for AssetMapper with minimal effect on existing apps. Hopefully we can get it totally smoothed out.

Cheers!

@xorgxx
Copy link

xorgxx commented May 29, 2023

thank's 🥡🍻||| it since to be back as normal .....

@stof
Copy link
Member

stof commented May 29, 2023

That way there will not be a v2.9 bundle that breaks a v6.2.x-dependent production system. It sounds as if stimulus-bundle should really be v6.3 or v6.4.

@gnito-org 2.9 is the version of symfony/ux, which has a versioning separate from symfony/symfony. StimulusBundle belongs to the UX monorepo, not to the framework monorepo.

@Geekimo
Copy link

Geekimo commented May 30, 2023

@weaverryan Hello, I've tried to apply the dual call to composer update (by doing composer update "symfony/*" -W because we only want to update Symfony dependencies), but I got an issue with symfony/asset-mapper.

PHP Fatal error:  During class fetch: Uncaught ReflectionException: Class "Symfony\Component\AssetMapper\Compiler\AssetCompilerPathResolverTrait" not found while loading "Symfony\UX\Vue\AssetMapper\VueControllerLoaderAssetCompiler". in [redacted]/vendor/symfony/error-handler/DebugClassLoader.php:297

@xorgxx
Copy link

xorgxx commented May 30, 2023

Hello i dont if it can help, but in my case the solution as @weaverryan said it was to update WebpackEncoreBundle to version 2.0

@Geekimo
Copy link

Geekimo commented May 30, 2023

@xorgxx Even after updating WebpackEncoreBundle to 2.x, I'm still having issues.

@lucasth-dev
Copy link

Being in Symfony 5.4 doesn't allow us to upgrade WebpackEncoreBundle to 2.x anyway

Still stuck here :(

@stof
Copy link
Member

stof commented May 30, 2023

@weaverryan it looks like the ux-vue VueControllerLoaderAssetCompiler class gets loaded even when asset-mapper is not installed while it uses its trait.

@weaverryan
Copy link
Member

@stof You're right. I had experienced that trait loading issue on CI somewhere... but it seemed to be only in some versions of Symfony (though I was never able to nail down exactly what the root cause was). Better to remove that service entirely. I'll get a PR going.

weaverryan added a commit that referenced this issue May 30, 2023
…as experimental (weaverryan)

This PR was squashed before being merged into the 2.x branch.

Discussion
----------

[StimulusBundle] Marking only the AssetMapper integration as experimental

| Q             | A
| ------------- | ---
| Bug fix?      | yesish
| New feature?  | no
| Tickets       | Addresses #907 (comment)
| License       | MIT

StimulusBundle should not really be experimental. The `stimulus_*` Twig functions were ported from WebpackEncoreBundle and should work the same (if they don't, that would be a bug).

The only part that should be experimental is the AssetMapper integration.

Cheers!

Commits
-------

71abb6f [StimulusBundle] Marking only the AssetMapper integration as experimental
@nbennett25
Copy link

nbennett25 commented May 30, 2023

@weaverryan still seeing the error using composer update with S6.x:

!! PHP Fatal error: During class fetch: Uncaught ReflectionException: Class "Symfony\Component\AssetMapper\Compiler\AssetCompilerPathResolverTrait" not found while loading "Symfony\UX\React\AssetMapper\ReactControllerLoaderAssetCompiler". in /Users/.../skeleton/vendor/symfony/error-handler/DebugClassLoader.php:297

is the fix not out yet...?

thx!

@stof
Copy link
Member

stof commented May 30, 2023

Are you using the 2.9.1 version of all the UX bundles ?

@Geekimo
Copy link

Geekimo commented May 30, 2023

@stof I don't think he does, it was released 12 minutes ago.

jameswebapp added a commit to jameswebapp/ux that referenced this issue Aug 1, 2023
…as experimental (weaverryan)

This PR was squashed before being merged into the 2.x branch.

Discussion
----------

[StimulusBundle] Marking only the AssetMapper integration as experimental

| Q             | A
| ------------- | ---
| Bug fix?      | yesish
| New feature?  | no
| Tickets       | Addresses symfony/ux#907 (comment)
| License       | MIT

StimulusBundle should not really be experimental. The `stimulus_*` Twig functions were ported from WebpackEncoreBundle and should work the same (if they don't, that would be a bug).

The only part that should be experimental is the AssetMapper integration.

Cheers!

Commits
-------

71abb6fa [StimulusBundle] Marking only the AssetMapper integration as experimental
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 a pull request may close this issue.

9 participants