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

[4.x]: Missing Class "yii\shell\Bootstrap" after Update to 4.3.8 #12647

Closed
kamejosh opened this issue Feb 8, 2023 · 7 comments
Closed

[4.x]: Missing Class "yii\shell\Bootstrap" after Update to 4.3.8 #12647

kamejosh opened this issue Feb 8, 2023 · 7 comments

Comments

@kamejosh
Copy link

kamejosh commented Feb 8, 2023

What happened?

Description

After upgrading Craft to the latest Version 4.3.8 a server error occurs. The same error occures when calling php craft migrate/all --no-content --interactive=0

I tried deleting vendor folder and composer.lock and running composer install again but the problem persists.

Steps to reproduce

  1. Have a Craft Project with Version 4.3.7
  2. update the project to craft 4.3.8
  3. run php craft migrate/all --no-content --interactive=0
  4. Error occurs

Expected behavior

No Error and Site should work

Actual behavior

Exception 'yii\di\NotInstantiableException' with message 'Failed to instantiate component or class "yii\shell\Bootstrap".'

in /.../vendor/yiisoft/yii2/di/Container.php:509

Caused by: Exception 'ReflectionException' with message 'Class "yii\shell\Bootstrap" does not exist'

in /.../vendor/yiisoft/yii2/di/Container.php:507

Stack trace:
#0 /.../vendor/yiisoft/yii2/di/Container.php(507): ReflectionClass->__construct('yii\\shell\\Boots...')
#1 /.../vendor/yiisoft/yii2/di/Container.php(385): yii\di\Container->getDependencies('yii\\shell\\Boots...')
#2 /.../vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('yii\\shell\\Boots...', Array, Array)
#3 /.../yiisoft/yii2/BaseYii.php(345): yii\di\Container->get('yii\\shell\\Boots...', Array)
#4 /.../vendor/yiisoft/yii2/base/Application.php(292): yii\BaseYii::createObject('yii\\shell\\Boots...')
#5 /.../vendor/craftcms/cms/src/console/Application.php(65): yii\base\Application->bootstrap()
#6 /.../vendor/yiisoft/yii2/base/Application.php(271): craft\console\Application->bootstrap()
#7 /.../vendor/yiisoft/yii2/console/Application.php(124): yii\base\Application->init()
#8 /.../vendor/craftcms/cms/src/console/Application.php(51): yii\console\Application->init()
#9 /.../vendor/yiisoft/yii2/base/BaseObject.php(109): craft\console\Application->init()
#10 /.../vendor/yiisoft/yii2/base/Application.php(204): yii\base\BaseObject->__construct(Array)
#11 /.../vendor/yiisoft/yii2/console/Application.php(89): yii\base\Application->__construct(Array)
#12 [internal function]: yii\console\Application->__construct(Array)
#13 /.../vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#14 /.../vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('craft\\console\\A...', Array, Array)
#15 /.../vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('craft\\console\\A...', Array, Array)
#16 /.../vendor/craftcms/cms/src/Craft.php(53): yii\BaseYii::createObject(Array, Array)
#17 /.../vendor/craftcms/cms/bootstrap/bootstrap.php(252): Craft::createObject(Array)
#18 /.../vendor/craftcms/cms/bootstrap/console.php(40): require('/home/webpages/...')
#19 /.../craft(12): require('/home/webpages/...')
#20 {main}

Craft CMS version

4.3.8

PHP version

8.1

Operating system and version

macOS 13.1 and Linux Ubuntu

Database type and version

Mysql 8.0.29

Image driver and version

No response

Installed plugins and versions

@kamejosh kamejosh changed the title [4.x]: [4.x]: Missing Class "yii\shell\Bootstrap" after Update to 4.3.8 Feb 8, 2023
@brandonkelly
Copy link
Member

brandonkelly commented Feb 8, 2023

Craft 3.7.65.1 and 4.3.8.1 have been released with a fix for this. Unfortunately, if you are currently running Craft 3.7.65 or 4.3.8, there’s nothing we can do to prevent you from running into this error the next time you update, though.

If you get the error, you will need to run composer update (or ddev composer update) to resolve. (No manual changes to cmoposer.json necessary.)

@MoritzLost
Copy link
Contributor

@brandonkelly Quick note for everyone, composer update will likely not work. Craft's update command (php craft update all) writes fixed version requirements in the composer.json, e.g.:

"require": {
    "craftcms/cms": "4.3.8",
},

composer update will only update new versions within the range defined in the composer.json, so it won't update to 4.3.8.1 in this case, since exactly 4.3.8 is required. You need composer require craftcms/cms:4.3.8.1 to change the requirement to that version and install it.

This only applies if you have a fixed version requirement like the one above in your composer.json, if you have a range like ^4.3.0, composer update will suffice.

@brandonkelly
Copy link
Member

@MoritzLost The bug is that the craftcms/plugin-installer and yiisoft/yii2-composer Composer plugins weren’t activated when updating to 4.3.8, even if they were specified in composer.json. So simply running composer update would at least get your site back into a working state. However you’re right – the bug would re-manifest itself after updating to 4.3.8.1. So manually changing the craftcms/cms requirement in composer.json to "4.3.8.1" and then running composer update is a better solution.

@khalwat
Copy link
Contributor

khalwat commented Feb 9, 2023

@MoritzLost
Copy link
Contributor

MoritzLost commented Feb 9, 2023

Might be helpful to some people: https://nystudio107.com/blog/updating-craft-cms-without-headaches#4-embrace-composer

@khalwat Slightly off-topic: I actually like that php craft update all writes fixed version requirements in the composer.json. This way, I can use php craft update all to update only Craft and plugins (which also performs any pending migrations). For other dependencies that aren't plugins, we use version ranges, so we can use composer update -W to update those independently of plugin updates. To each their own I guess :)

@khalwat
Copy link
Contributor

khalwat commented Feb 9, 2023

@MoritzLost use what works for you -- I find that avoiding the Craft layer has been more reliable for me.

@uandco
Copy link

uandco commented Feb 10, 2023

Do you mean these 2 components were not in allow-plugins?
I ran into the same issue but when running a manual composer update, composer also wanted to allow this one:

php-http/discovery contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins
Do you trust "php-http/discovery" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?]

If I accept, it then goes into a endless loop after Nothing to modify in lock file:

- Installing psy/psysh (v0.11.12): Extracting archive
- Installing yiisoft/yii2-shell (2.0.5): Extracting archive
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package league/uri-parser is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
94 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 0 updates, 0 removals
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package league/uri-parser is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
94 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
[etc]

The only way to get around the loop is to either discard (but they I get asked every time I run composer update or deny, but not sure what are the implications of setting "php-http/discovery": false in allow-plugins

Update: it seems like php-http/discovery 1.15.0 is causing this issue, this is not related to Craft, see php-http/discovery#212

@brandonkelly brandonkelly unpinned this issue Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants