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]: Running craft update all/pluginhandle breaks site #11399

Closed
alexr8 opened this issue Jun 8, 2022 · 19 comments
Closed

[4.x]: Running craft update all/pluginhandle breaks site #11399

alexr8 opened this issue Jun 8, 2022 · 19 comments
Assignees

Comments

@alexr8
Copy link

alexr8 commented Jun 8, 2022

What happened?

Description

When running php craft update all or php craft update handle, an error is encountered that breaks the site. The error in terminal is: error: The command "'/usr/local/bin/php' '/app/craft' 'migrate/all' '--no-backup' '--no-content'" failed. (more output below)

When loading pages on the front-end, the following error is displayed:

Not instantiable – [yii\di\NotInstantiableException](http://www.yiiframework.com/doc-2.0/yii-di-notinstantiableexception.html) Failed to instantiate component or class "yii\shell\Bootstrap". ↵ Caused by: ReflectionException Class "yii\shell\Bootstrap" does not exist

To fix, i restore the database, delete my vendor folder, and run composer install to restore to its previous state.

Steps to reproduce

  1. Run php craft update on all plugins or a single plugin (doesn't appear to matter which one) from the terminal.

Expected behavior

The plugin(s) should be updated to the latest version.

Actual behavior

The update fails with the following readout (full):

`Backing up the database ... done
Performing update with Composer ... done
Applying new migrations ... error: The command "'/usr/local/bin/php' '/app/craft' 'migrate/all' '--no-backup' '--no-content'" failed.

Exit Code: 1(General error)

Working directory: /app

Output:

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

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

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

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

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

Craft CMS version

4.0.3

PHP version

8.0.11

Operating system and version

Nitro

Database type and version

MySQL 8.0

Image driver and version

No response

Installed plugins and versions

"craftcms/aws-s3": "2.0.1",
"craftcms/cms": "^4.0.0",
"craftcms/feed-me": "5.0.4",
"craftcms/redactor": "3.0.0",
"hybridinteractive/craft-position-fieldtype": "4.0.0-beta.3",
"leowebguy/mix-manifest": "1.0.1",
"mmikkel/retcon": "2.4.2",
"nystudio107/craft-cookies": "4.0.0",
"nystudio107/craft-seomatic": "4.0.0",
"percipiolondon/craft-tweet-feed": "4.0.0",
"putyourlightson/craft-sprig": "2.0.1",
"sebastianlenz/linkfield": "2.1.3-rc",
"solspace/craft-freeform": "4.0.0-beta.8",
"solspace/craft3-calendar": "4.0.0-beta.4",
"spacecatninja/imager-x": "4.0.1",
"spicyweb/craft-embedded-assets": "3.0.1",
"verbb/image-resizer": "3.0.0-beta.1",
"verbb/knock-knock": "2.0.0-beta.1",
"verbb/super-table": "3.0.0-beta.4",
"vlucas/phpdotenv": "^3.4.0"

@brandonkelly
Copy link
Member

Do you have the composer.json and composer.lock files from before this happened? If so please post them here or send them into [email protected], and we can try to reproduce from there.

@alexr8
Copy link
Author

alexr8 commented Jun 9, 2022

composer-files.zip

I manually upgraded from craft 3 to craft 4, editing each plugin in turn in the composer file. Plugins all installed fine although some plugins had bugs (that didnt hinder the installation at least). After this point, running update via the CLI brings the above issues. Unsure if it could be one of the plugins that is blocking the migrations running?

@JansonChe
Copy link

I ran into the same issue while updating vom 4.0.2 to 4.0.4 using nitro php craft update craft.

@alexr8
Copy link
Author

alexr8 commented Jun 12, 2022

@JansonChe did you find a workaround at all?

@adrienpicard
Copy link

I'm getting the same error trying to update any plugin on a 3.7.43 install.

@JansonChe
Copy link

@JansonChe did you find a workaround at all?

Not really, no, I just rolled back to the version that was working (vendor folder deleted and dependencies re-installed). Because this update is not a critical/urgent one for my project, I've decided to wait and check for progress on this issue. How about you @alexr8 ?

@christophstockinger
Copy link

Same problem! Migrations do not work. I have been waiting for over half an hour for something to happen. However, I still get the following message on the console.
image

Currently I can not recommend to upgrade to Craft4!

@brandonkelly
Copy link
Member

@christophstockinger That looks like a separate issue. (This one affects Craft 3 and 4, and is Composer-specific, not a v4 migration issue.) Please either post as a new issue here, or get in touch via [email protected].

@angrybrad
Copy link
Member

@adrienpicard Is your local development environment Nitro as well?

@adrienpicard
Copy link

@angrybrad no I should have said sorry, it's a homebrew PHP / MariaDB install running on macOS.

PHP version
8.1.5

Operating system and version
macOS 12.3.1

Database type and version
MariaDB 10.6.4

@angrybrad
Copy link
Member

I'm not able to reproduce locally or with @alexr8's files, unfortunately.

Any chance anyone can replicate this on a public box we can get some SSH/Craft control panel access to?

@adrienpicard
Copy link

@angrybrad I'm working on a few projects at the moment but am only facing this issue with one. All Craft 3.7.* installs, all using the same dev environment. Happy to share more details if that helps.

@JansonChe
Copy link

@angrybrad @alexr8 Hmmm I have two projects that where very similar in their environment and versions, but only one had this problem when trying to update. While comparing the two composer.json files the only real difference was:

"config": {
        "allow-plugins": {
            "craftcms/plugin-installer": true,
            "yiisoft/yii2-composer": true
        },
    }

The failing project was missing these lines, but it added only "craftcms/plugin-installer": true when updating with: nitro php craft update craft. But when I manually added "yiisoft/yii2-composer": true and tried running the update again, it worked. I'm not sure why and how, but maybe it's a hint?

@adrienpicard
Copy link

@JansonChe @angrybrad can confirm manually adding "yiisoft/yii2-composer": true to my composer.json file fixed the issue for me too.

@alexr8
Copy link
Author

alexr8 commented Jun 22, 2022

@angrybrad i've made some progress in that I:

  • ran craft update all
  • waited for the error to get thrown
  • restored the database but didn't revert the composer file
  • deleted vendor
  • composer installed all the later versions of plugins
  • then went to /admin and clicked the 'finish up' button to apply necessary database changes, and these were made successfully.

As there are currently no new updates available as i've just installed the latest, i can't test whether php craft update all will now work, but potentially it might? If not I'll give @JansonChe suggestion a whirl.

edit: seeing that the "yiisoft/yii2-composer": true is default in new craft 4 installs composer.json i'll go ahead and add it anyway as i guess it should in there.

@accarpenter
Copy link

Was getting the same issue. When running an update for Craft or any plugin I got an undefined error. Adding "yiisoft/yii2-composer": true under config in composer.json fixed this for me too.

@brandonkelly
Copy link
Member

I’ve just updated Craft’s internal Composer commands to ensure that yiisoft/yii2-composer is enabled in composer.json before triggering Composer.

That change is out now in 3.7.45.2 and 4.0.5.2, however it won’t kick in until you’re already running at least one of those Craft versions.

@kellyannmcnamara01
Copy link

Sorry to bring this up again.

Actions:
trying to update local

Error:
A fatal error has occurred: Status: undefined, Response: undefined

Important notes:

  • PHP 8.0.8
  • OS Darwin 22.6.0
  • Craft Pro 4.5.4 (trying to update)
  • Database MySQL 5.7.34
  • Yii 2.0.48.1
  • I already have the allow-plugins config setting in the composer file
    "allow-plugins": { "craftcms/plugin-installer": true,"yiisoft/yii2-composer": true}

@brandonkelly
Copy link
Member

Hey @kellyannmcnamara01! Check storage/logs/phperrors.log. Anything reported in there, with about the same timestamp as when the error occurred?

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

8 participants