Jump to content

Trouble shooting Composer and fixed package by partial update


NotionCommotion

Recommended Posts

How should one go about troubleshooting composer?  composer.lock does in fact show doctrine/dbal as 3.3.2.  I don't think that my composer.json shown at the bottom is causing this.  What does it mean regarding "by a partial update"?  Thanks

 

$ docker-compose exec php \
>     composer require brick/phonenumber-doctrine
Using version ^0.1.1 for brick/phonenumber-doctrine
./composer.json has been updated
Running composer update brick/phonenumber-doctrine
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires brick/phonenumber-doctrine ^0.1.1 -> satisfiable by brick/phonenumber-doctrine[0.1.1].
    - brick/phonenumber-doctrine 0.1.1 requires doctrine/dbal ^2.7.0 -> found doctrine/dbal[v2.7.0, ..., 2.13.7] but the package is fixed to 3.3.2 (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.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require brick/phonenumber-doctrine:*" to figure out if any version is installable, or "composer require brick/phonenumber-doctrine:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
$

composer.lock (partial)

        {
            "name": "doctrine/dbal",
            "version": "3.3.2",
            "source": {
                "type": "git",
                "url": "https://github.com/doctrine/dbal.git",
                "reference": "35eae239ef515d55ebb24e9d4715cad09a4f58ed"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/doctrine/dbal/zipball/35eae239ef515d55ebb24e9d4715cad09a4f58ed",
                "reference": "35eae239ef515d55ebb24e9d4715cad09a4f58ed",
                "shasum": ""
            },
            "require": {
                "composer-runtime-api": "^2",
                "doctrine/cache": "^1.11|^2.0",
                "doctrine/deprecations": "^0.5.3",
                "doctrine/event-manager": "^1.0",
                "php": "^7.3 || ^8.0",
                "psr/cache": "^1|^2|^3",
                "psr/log": "^1|^2|^3"
            },
            "require-dev": {
                "doctrine/coding-standard": "9.0.0",
                "jetbrains/phpstorm-stubs": "2021.1",
                "phpstan/phpstan": "1.4.0",
                "phpstan/phpstan-strict-rules": "^1.1",
                "phpunit/phpunit": "9.5.11",
                "psalm/plugin-phpunit": "0.16.1",
                "squizlabs/php_codesniffer": "3.6.2",
                "symfony/cache": "^5.2|^6.0",
                "symfony/console": "^2.7|^3.0|^4.0|^5.0|^6.0",
                "vimeo/psalm": "4.16.1"
            },
            "suggest": {
                "symfony/console": "For helpful console commands such as SQL execution and import of files."
            },
            "bin": [
                "bin/doctrine-dbal"
            ],
            "type": "library",
            "autoload": {
                "psr-4": {
                    "Doctrine\\DBAL\\": "src"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Guilherme Blanco",
                    "email": "guilhermeblanco@gmail.com"
                },
                {
                    "name": "Roman Borschel",
                    "email": "roman@code-factory.org"
                },
                {
                    "name": "Benjamin Eberlei",
                    "email": "kontakt@beberlei.de"
                },
                {
                    "name": "Jonathan Wage",
                    "email": "jonwage@gmail.com"
                }
            ],
            "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.",
            "homepage": "https://www.doctrine-project.org/projects/dbal.html",
            "keywords": [
                "abstraction",
                "database",
                "db2",
                "dbal",
                "mariadb",
                "mssql",
                "mysql",
                "oci8",
                "oracle",
                "pdo",
                "pgsql",
                "postgresql",
                "queryobject",
                "sasql",
                "sql",
                "sqlite",
                "sqlserver",
                "sqlsrv"
            ],
            "support": {
                "issues": "https://github.com/doctrine/dbal/issues",
                "source": "https://github.com/doctrine/dbal/tree/3.3.2"
            },
            "funding": [
                {
                    "url": "https://www.doctrine-project.org/sponsorship.html",
                    "type": "custom"
                },
                {
                    "url": "https://www.patreon.com/phpdoctrine",
                    "type": "patreon"
                },
                {
                    "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal",
                    "type": "tidelift"
                }
            ],
            "time": "2022-02-05T16:33:45+00:00"
        },

composer.json (partial)

{
    "require": {
        "brick/phonenumber": "^0.4.0",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "^2.4",
        "doctrine/doctrine-migrations-bundle": "^3.0",
        "doctrine/orm": "^2.9"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.4"
    }
}

 

Link to comment
Share on other sites

39 minutes ago, requinix said:

I'd just not bother and do the same thing I do when NPM and Cargo (Rust) have problems: delete the lock file and reinstall. That should fix any "partial" thing that put you into a weird state.

No change.  Just to be "extra sure", even deleted the vendor directory.

EDIT - Just deleted it again and did the composer require package instead of install and then it worked.  Why I have no idea...

Edited by NotionCommotion
Link to comment
Share on other sites

1 hour ago, NotionCommotion said:

EDIT - Just deleted it again and did the composer require package instead of install and then it worked.  Why I have no idea...

When require fails it reverts the files.  As such, your new package wouldn't be considered when you did the install and you just end up back in the same situation again.  Doing the require first allows composer to resolve everything while taking that new package you want into consideration.

I think what the original error was trying to say is that the new package you want to install needs doctrine/dbal in the v2.7.0, ..., 2.13.7 but you currently have doctrine/dbal 3.3.2 installed and it's refusing to downgrade it automatically.  Re-running with the --with-all-dependencies flag as it suggested probably would have worked as well.

Link to comment
Share on other sites

Thanks kicken,  After "kind of" getting this working, I noticed that many of my installed packaged are now older.  I would rather not use this brick/phonenumber-doctrine package than do so.  Will the --with-all-dependencies flag  tell composer to ignore that I am using a more current doctrine/dbal 3.3.2 or tell it to downgrade it automatically?

Link to comment
Share on other sites

On 2/8/2022 at 10:45 AM, NotionCommotion said:

Will the --with-all-dependencies flag  tell composer to ignore that I am using a more current doctrine/dbal 3.3.2 or tell it to downgrade it automatically?

The latter.
 

$ docker-compose exec php      composer require brick/phonenumber-doctrine --with-all-dependencies
Using version ^0.1.1 for brick/phonenumber-doctrine
./composer.json has been updated
Running composer update brick/phonenumber-doctrine --with-all-dependencies
Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "5.3.*"
Updating dependencies
Lock file operations: 1 install, 1 update, 0 removals
  - Locking brick/phonenumber-doctrine (0.1.1)
  - Downgrading doctrine/dbal (3.3.2 => 2.13.7)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 1 update, 0 removals
  - Downloading doctrine/dbal (2.13.7)
  - Downloading brick/phonenumber-doctrine (0.1.1)
  - Downgrading doctrine/dbal (3.3.2 => 2.13.7): Extracting archive
  - Installing brick/phonenumber-doctrine (0.1.1): Extracting archive
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
101 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

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]

$

 

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.