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

Composer 2.2+ breaks composer update <package> in monorepos #10431

Closed
anomiex opened this issue Jan 4, 2022 · 5 comments
Closed

Composer 2.2+ breaks composer update <package> in monorepos #10431

anomiex opened this issue Jan 4, 2022 · 5 comments
Labels
Milestone

Comments

@anomiex
Copy link

anomiex commented Jan 4, 2022

In a monorepo where package C depends on B which depends on A, and C has a lockfile, trying to do a composer update <package> in C will fail due to Composer not "loading" A at all. This seems to have been caused by #10157.

Note that in the example given below, nothing is being changed by the composer update. You may also want to have a look at renovatebot/renovate#13371, in which some things actually are being changed.

My composer.json:

test.zip

Output of composer diagnose:

Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 2.3-dev+711f436b2431ebf2845ee89a556ffde619212405
PHP version: 8.0.14
PHP binary path: /usr/bin/php8.0
OpenSSL version: OpenSSL 1.1.1l  24 Aug 2021
cURL version: 7.79.1 libz 1.2.11 ssl OpenSSL/1.1.1l
zip: extension not loaded, unzip present, 7-Zip not available

When I run this command:

composer -vvv -d c update composer/semver

I get the following output:

Output
Changed CWD to /tmp/test/c
Reading ./composer.json (/tmp/test/c/composer.json)
Loading config file /home/anomiex/.config/composer/config.json
Loading config file /home/anomiex/.config/composer/auth.json
Loading config file ./composer.json (/tmp/test/c/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/tmp/test/c): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/c): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/tmp/test/c): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/c): hg branch
Executing command (/tmp/test/c): fossil branch list
Executing command (/tmp/test/c): fossil tag list
Executing command (/tmp/test/c): svn info --xml
Reading /home/anomiex/.config/composer/composer.json
Loading config file /home/anomiex/.config/composer/config.json
Loading config file /home/anomiex/.config/composer/auth.json
Loading config file /home/anomiex/.config/composer/composer.json (/home/anomiex/.config/composer/composer.json)
Loading config file /home/anomiex/.config/composer/auth.json
Reading /home/anomiex/.config/composer/auth.json
Running 2.3-dev+711f436b2431ebf2845ee89a556ffde619212405 (2022-01-04 15:31:45) with PHP 8.0.14 on Linux / 5.15.0-2-amd64
Reading ./composer.lock (/tmp/test/c/composer.lock)
Loading composer repositories with package information
Executing command (/tmp/test/a/): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/a/): git describe --exact-match --tags
Executing command (/tmp/test/a/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/a/): hg branch
Executing command (/tmp/test/a/): fossil branch list
Executing command (/tmp/test/a/): fossil tag list
Executing command (/tmp/test/a/): svn info --xml
Executing command (/tmp/test/b/): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/b/): git describe --exact-match --tags
Executing command (/tmp/test/b/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/b/): hg branch
Executing command (/tmp/test/b/): fossil branch list
Executing command (/tmp/test/b/): fossil tag list
Executing command (/tmp/test/b/): svn info --xml
Executing command (/tmp/test/c/): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/c/): git describe --exact-match --tags
Executing command (/tmp/test/c/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/c/): hg branch
Executing command (/tmp/test/c/): fossil branch list
Executing command (/tmp/test/c/): fossil tag list
Executing command (/tmp/test/c/): svn info --xml
Reading /home/anomiex/.cache/composer/repo/https---repo.packagist.org/packages.json from cache
Downloading https://repo.packagist.org/packages.json if modified
[304] https://repo.packagist.org/packages.json
Reading /home/anomiex/.cache/composer/repo/https---repo.packagist.org/provider-composer~semver.json from cache
Downloading https://repo.packagist.org/p2/composer/semver.json if modified
Reading /home/anomiex/.cache/composer/repo/https---repo.packagist.org/provider-composer~semver~dev.json from cache
Downloading https://repo.packagist.org/p2/composer/semver~dev.json if modified
[304] https://repo.packagist.org/p2/composer/semver.json
[304] https://repo.packagist.org/p2/composer/semver~dev.json
Updating dependencies
Generating rules
Resolving dependencies through SAT

Dependency resolution completed in 0.002 seconds
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - monorepo/b[dev-main, dev-master] require monorepo/a @dev -> found monorepo/a[dev-master (alias of dev-main), dev-main] but these were not loaded, likely because it conflicts with another require.
    - monorepo/b dev-master is an alias of monorepo/b dev-main and thus requires it to be installed too.
    - Root composer.json requires monorepo/b @dev -> satisfiable by monorepo/b[dev-master (alias of dev-main), dev-main].

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

Note that specifying --with-all-dependencies makes no difference.

And I expected this to happen:

Output
Changed CWD to /tmp/test/c
Reading ./composer.json (/tmp/test/c/composer.json)
Loading config file /home/anomiex/.config/composer/config.json
Loading config file /home/anomiex/.config/composer/auth.json
Loading config file ./composer.json (/tmp/test/c/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/tmp/test/c): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/c): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/tmp/test/c): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/c): hg branch
Executing command (/tmp/test/c): fossil branch list
Executing command (/tmp/test/c): fossil tag list
Executing command (/tmp/test/c): svn info --xml
Reading /home/anomiex/.config/composer/composer.json
Loading config file /home/anomiex/.config/composer/config.json
Loading config file /home/anomiex/.config/composer/auth.json
Loading config file /home/anomiex/.config/composer/composer.json (/home/anomiex/.config/composer/composer.json)
Loading config file /home/anomiex/.config/composer/auth.json
Reading /home/anomiex/.config/composer/auth.json
Running 2.3-dev+711f436b2431ebf2845ee89a556ffde619212405 (2022-01-04 15:31:45) with PHP 8.0.14 on Linux / 5.15.0-2-amd64
Reading ./composer.lock (/tmp/test/c/composer.lock)
Loading composer repositories with package information
Executing command (/tmp/test/a/): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/a/): git describe --exact-match --tags
Executing command (/tmp/test/a/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/a/): hg branch
Executing command (/tmp/test/a/): fossil branch list
Executing command (/tmp/test/a/): fossil tag list
Executing command (/tmp/test/a/): svn info --xml
Executing command (/tmp/test/b/): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/b/): git describe --exact-match --tags
Executing command (/tmp/test/b/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/b/): hg branch
Executing command (/tmp/test/b/): fossil branch list
Executing command (/tmp/test/b/): fossil tag list
Executing command (/tmp/test/b/): svn info --xml
Executing command (/tmp/test/c/): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/c/): git describe --exact-match --tags
Executing command (/tmp/test/c/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/c/): hg branch
Executing command (/tmp/test/c/): fossil branch list
Executing command (/tmp/test/c/): fossil tag list
Executing command (/tmp/test/c/): svn info --xml
Reading /home/anomiex/.cache/composer/repo/https---repo.packagist.org/packages.json from cache
Downloading https://repo.packagist.org/packages.json if modified
[304] https://repo.packagist.org/packages.json
Reading /home/anomiex/.cache/composer/repo/https---repo.packagist.org/provider-composer~semver.json from cache
Downloading https://repo.packagist.org/p2/composer/semver.json if modified
Reading /home/anomiex/.cache/composer/repo/https---repo.packagist.org/provider-composer~semver~dev.json from cache
Downloading https://repo.packagist.org/p2/composer/semver~dev.json if modified
[304] https://repo.packagist.org/p2/composer/semver.json
[304] https://repo.packagist.org/p2/composer/semver~dev.json
Updating dependencies
Generating rules
Resolving dependencies through SAT
Looking at all rules.
Something's changed, looking at all rules again (pass #1)
Dependency resolution completed in 0.001 seconds
Analyzed 98 packages to resolve dependencies
Analyzed 101 rules to resolve dependencies
Lock file operations: 0 installs, 0 updates, 0 removals
Installing dependencies from lock file (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
Installs: composer/semver:3.2.6, monorepo/a:dev-main, monorepo/b:dev-main
Reading /home/anomiex/.cache/composer/files/composer/semver/8c20821cfc99ed0b1d30e64525d268163cce06c3.zip from cache
  - Loading composer/semver (3.2.6) from cache
  - Installing composer/semver (3.2.6): Extracting archive
Executing async command (CWD): '/usr/bin/unzip' -qq '/tmp/test/c/vendor/composer/tmp-f0957967fdd38dc053d74dada35e8150' -d '/tmp/test/c/vendor/composer/91084dfd'
  - Installing monorepo/a (dev-main): Symlinking from ../a
  - Installing monorepo/b (dev-main): Symlinking from ../b
Executing async command (CWD): rm -rf '/tmp/test/c/vendor/composer/91084dfd'
Downloading https://packagist.org/downloads/
[201] https://packagist.org/downloads/
Generating autoload files
1 package you are using is looking for funding.
Use the `composer fund` command to find out more!

Or, if composer install had been run previously,

Output
Changed CWD to /tmp/test/c
Reading ./composer.json (/tmp/test/c/composer.json)
Loading config file /home/anomiex/.config/composer/config.json
Loading config file /home/anomiex/.config/composer/auth.json
Loading config file ./composer.json (/tmp/test/c/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/tmp/test/c): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/c): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/tmp/test/c): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/c): hg branch
Executing command (/tmp/test/c): fossil branch list
Executing command (/tmp/test/c): fossil tag list
Executing command (/tmp/test/c): svn info --xml
Reading /home/anomiex/.config/composer/composer.json
Loading config file /home/anomiex/.config/composer/config.json
Loading config file /home/anomiex/.config/composer/auth.json
Loading config file /home/anomiex/.config/composer/composer.json (/home/anomiex/.config/composer/composer.json)
Loading config file /home/anomiex/.config/composer/auth.json
Reading /home/anomiex/.config/composer/auth.json
Reading /tmp/test/c/vendor/composer/installed.json
Running 2.3-dev+711f436b2431ebf2845ee89a556ffde619212405 (2022-01-04 15:31:45) with PHP 8.0.14 on Linux / 5.15.0-2-amd64
Reading ./composer.lock (/tmp/test/c/composer.lock)
Loading composer repositories with package information
Executing command (/tmp/test/a/): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/a/): git describe --exact-match --tags
Executing command (/tmp/test/a/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/a/): hg branch
Executing command (/tmp/test/a/): fossil branch list
Executing command (/tmp/test/a/): fossil tag list
Executing command (/tmp/test/a/): svn info --xml
Executing command (/tmp/test/b/): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/b/): git describe --exact-match --tags
Executing command (/tmp/test/b/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/b/): hg branch
Executing command (/tmp/test/b/): fossil branch list
Executing command (/tmp/test/b/): fossil tag list
Executing command (/tmp/test/b/): svn info --xml
Executing command (/tmp/test/c/): git branch -a --no-color --no-abbrev -v
Executing command (/tmp/test/c/): git describe --exact-match --tags
Executing command (/tmp/test/c/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/tmp/test/c/): hg branch
Executing command (/tmp/test/c/): fossil branch list
Executing command (/tmp/test/c/): fossil tag list
Executing command (/tmp/test/c/): svn info --xml
Reading /home/anomiex/.cache/composer/repo/https---repo.packagist.org/packages.json from cache
Downloading https://repo.packagist.org/packages.json if modified
[304] https://repo.packagist.org/packages.json
Reading /home/anomiex/.cache/composer/repo/https---repo.packagist.org/provider-composer~semver.json from cache
Downloading https://repo.packagist.org/p2/composer/semver.json if modified
Reading /home/anomiex/.cache/composer/repo/https---repo.packagist.org/provider-composer~semver~dev.json from cache
Downloading https://repo.packagist.org/p2/composer/semver~dev.json if modified
[304] https://repo.packagist.org/p2/composer/semver.json
[304] https://repo.packagist.org/p2/composer/semver~dev.json
Updating dependencies
Generating rules
Resolving dependencies through SAT
Looking at all rules.
Something's changed, looking at all rules again (pass #1)
Dependency resolution completed in 0.001 seconds
Analyzed 98 packages to resolve dependencies
Analyzed 101 rules to resolve dependencies
Lock file operations: 0 installs, 0 updates, 0 removals
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
1 package you are using is looking for funding.
Use the `composer fund` command to find out more!
@mpyw
Copy link

mpyw commented Jan 5, 2022

I think that Path Repositories should handle both dev-master and dev-main. Otherwise, I'm pretty sure the 2.2 update has an unintended breaking changes.

@mpyw
Copy link

mpyw commented Jan 5, 2022

Also Related: #10360 #10372 24eac88

@Seldaek The following logic seems to be not working anymore because of #10157? 😢
24eac88#diff-9743373314ae0979eeffb3005e1d24b4a83c67449fd8fd41b94bb8dae95ce1e8R218-R221

@anomiex
Copy link
Author

anomiex commented Jan 5, 2022

This does not seem to have anything to do with dev-master versus dev-main.

@Seldaek Seldaek closed this as completed in 641ad10 Jan 7, 2022
@Seldaek
Copy link
Member

Seldaek commented Jan 7, 2022

@anomiex thanks for the great reproducer. This helped a lot. And indeed it was related to the dev-main alias. You can try with composer self-update --snapshot if it really fixes the problem for you in a real world scenario.

@Seldaek Seldaek added this to the 2.2 milestone Jan 7, 2022
@Seldaek Seldaek added the Bug label Jan 7, 2022
@anomiex
Copy link
Author

anomiex commented Jan 7, 2022

Seems to work so far! If I run into more problems, I'll let you know.

Thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants