craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

[4.x]: Composer error when updating from 3 to 4 #12985

Closed CelularPrism closed 1 year ago

CelularPrism commented 1 year ago

What happened?

Description

I can't update Craft CMS from 3 to 4.0.0 using composer:

composer update .
Problem 1
    - Root composer.json requires craftcms/cms ^4.0.0, found craftcms/cms[4.0.0-beta.1, ..., 4.4.5] but the package is fixed to 3.8.5 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific `versions.`

Steps to reproduce

  1. Update composer.json: 1.1. "php": ">=7.0.0" -> "php": ">=8.0.2" 1.2. "craftcms/cms": "^3.0.0-beta.1" -> "craftcms/cms": "^4.0.0"
  2. Run composer update .
  3. Get the error

Expected behavior

No error.

Actual behavior

Error.

Craft CMS version

3.8.5

PHP version

8.1.5

Operating system and version

WINNT 6.2

Database type and version

MariaDB 10.6.7

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.0-18)

Installed plugins and versions

-

i-just commented 1 year ago

Hi, thanks for reaching out. It sounds like one of the plugins you’re using requires Craft 3. Did you also update all the plugin versions to ones compatible with Craft 4? In case it helps, you can find the upgrade guide here: https://craftcms.com/docs/4.x/upgrade.html

CelularPrism commented 1 year ago

Hi. Of the installed plugins, I only have "vlucas/phpdotenv": "^2.4.0" and if I install version ^5.4.0, then there will be 2 similar problems with craftcms and phpdotenv. Attach the composer.json file below

{
  "name": "craftcms/craft",
  "description": "Craft CMS",
  "keywords": [
    "craft",
    "cms",
    "craftcms",
    "project"
  ],
  "license": "MIT",
  "homepage": "https://craftcms.com/",
  "type": "project",
  "support": {
    "email": "support@craftcms.com",
    "issues": "https://github.com/craftcms/cms/issues?state=open",
    "forum": "https://craftcms.stackexchange.com/",
    "source": "https://github.com/craftcms/cms",
    "docs": "https://craftcms.com/docs",
    "rss": "https://craftcms.com/changelog.rss"
  },
  "minimum-stability": "beta",
  "require": {
    "php": ">=8.0.2",
    "craftcms/cms": "^4.0.0",
    "craftcms/plugin-installer": "^1.0.0",
    "vlucas/phpdotenv": "^5.4.0",
    "roave/security-advisories": "dev-master"
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://asset-packagist.org"
    }
  ],
  "config": {
    "allow-plugins": {
      "yiisoft/yii2-composer": true,
      "craftcms/plugin-installer": true
    }
  }
}
i-just commented 1 year ago

Try running just composer update - without the full stop at the end, and it should work as expected. I was able to replicate the behaviour you described when I added that full stop.

Updating to "vlucas/phpdotenv": "^5.4.0", is a good call too.

CelularPrism commented 1 year ago

Yep, this is call new problem with my PHP settings in php.ini. It was necessary to remove ; in the line extension = intl