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

defaults to wrong version of php81_bc/strftime on some systems #10884

Closed
divinity76 opened this issue Jun 19, 2022 · 2 comments · Fixed by #10896
Closed

defaults to wrong version of php81_bc/strftime on some systems #10884

divinity76 opened this issue Jun 19, 2022 · 2 comments · Fixed by #10896
Labels
Milestone

Comments

@divinity76
Copy link

divinity76 commented Jun 19, 2022

when installing php81_bc/strftime on some systems, Composer defaults to version 0.0.2, not version 0.5.0, with the command composer require php81_bc/strftime, this has been observed:

  • Composer version 2.2.4 on Debian 10 Linux defaults to version 0.0.2
  • Composer version 2.3.7 on Ubuntu 20.04 Linux defaults to version 0.0.2.
  • Composer version 2.3.7 on Windows defaults to version 0.5.0
  • Composer version 1.10.1 on Ubuntu 20.04 Linux defaults to version 0.5.0
  • Composer version 2.0.1 on CentOS6 Linux defaults to version 0.5.0
  • using the alternative command composer require php81_bc/strftime ^0.5.0 installs 0.5.0 every time.

My composer.json:

{}

(composer.json doesn't have to exist to reproduce the issue)

Output of composer diagnose:

Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: 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.7
PHP version: 7.4.3
PHP binary path: /usr/bin/php7.4
OpenSSL version: OpenSSL 1.1.1f  31 Mar 2020
cURL version: missing, using php streams fallback, which reduces performance
zip: extension not loaded, unzip not available, 7-Zip not available

When I run this command:

./composer.phar -vvv require php81_bc/strftime

I get the following output:

Running 2.3.7 (2022-06-06 16:43:28) with PHP 7.4.3 on Linux / 5.4.0-113-generic
Failed to initialize global composer: Composer could not find the config file: /root/.composer/composer.json
To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage
Reading ./composer.json (/composer.json)
Loading config file ./composer.json (/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 (/): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Executing command (/): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/): hg branch
Executing command (/): fossil branch list
Executing command (/): fossil tag list
Executing command (/): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /root/.composer/composer.json

Downloading https://repo.packagist.org/packages.json
Info from https://repo.packagist.org: #StandWithUkraine
Writing /root/.composer/cache/repo/https---repo.packagist.org/packages.json into cache
Downloading https://repo.packagist.org/p2/php81_bc/strftime.json
Writing /root/.composer/cache/repo/https---repo.packagist.org/provider-php81-bc~strftime.json into cache
Using version ^0.0.2 for php81_bc/strftime
./composer.json has been created
Reading ./composer.json (/composer.json)
Loading config file ./composer.json (/composer.json)
Executing command (/): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Executing command (/): git describe --exact-match --tags
Executing command (/): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/): hg branch
Executing command (/): fossil branch list
Executing command (/): fossil tag list
Executing command (/): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /root/.composer/composer.json

Running composer update php81_bc/strftime
Loading composer repositories with package information
Reading /root/.composer/cache/repo/https---repo.packagist.org/packages.json from cache
Downloading https://repo.packagist.org/packages.json
Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-php81-bc~strftime.json from cache
Downloading https://repo.packagist.org/p2/php81_bc/strftime.json
Built pool.
Running pool optimizer.
Updating dependencies
Generating rules
Resolving dependencies through SAT
Looking at all rules.

Dependency resolution completed in 0.000 seconds
Analyzed 50 packages to resolve dependencies
Analyzed 51 rules to resolve dependencies
Lock file operations: 1 install, 0 updates, 0 removals
Installs: php81_bc/strftime:0.0.2
  - Locking php81_bc/strftime (0.0.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Reading ./composer.lock (/composer.lock)
Package operations: 1 install, 0 updates, 0 removals
Installs: php81_bc/strftime:0.0.2
    Failed to download php81_bc/strftime from dist: The zip extension and unzip/7z commands are both missing, skipping.
Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
    Now trying to download from source
  - Syncing php81_bc/strftime (0.0.2) into cache
    Cloning to cache at '/root/.composer/cache/vcs/https---github.com-alphp-strftime.git/'
Executing command (CWD): git clone --mirror -- 'https://github.com/alphp/strftime.git' '/root/.composer/cache/vcs/https---github.com-alphp-strftime.git/'
Executing command (/root/.composer/cache/vcs/https---github.com-alphp-strftime.git/): git rev-parse --git-dir
Executing command (/root/.composer/cache/vcs/https---github.com-alphp-strftime.git/): git rev-parse --quiet --verify 'a6b25e3e2ee931faf3d80bb5c0fba3552300d02a^{commit}'
  - Installing php81_bc/strftime (0.0.2): Cloning a6b25e3e2ee931faf3d80bb5c0fba3552300d02a from cache
Executing command (CWD): git clone --no-checkout '/root/.composer/cache/vcs/https---github.com-alphp-strftime.git/' '/vendor/php81_bc/strftime' --dissociate --reference '/root/.composer/cache/vcs/https---github.com-alphp-strftime.git/' && cd '/vendor/php81_bc/strftime' && git remote set-url origin -- 'https://github.com/alphp/strftime.git' && git remote add composer -- 'https://github.com/alphp/strftime.git'
Executing command (/vendor/php81_bc/strftime): git remote set-url --push origin -- 'git@github.com:alphp/strftime.git'
Executing command (/vendor/php81_bc/strftime): git branch -r
Executing command (/vendor/php81_bc/strftime): (git checkout '0.0.2' -- || git checkout -B '0.0.2' 'composer/0.0.2' --) && git reset --hard 'a6b25e3e2ee931faf3d80bb5c0fba3552300d02a' --
Downloading https://packagist.org/downloads/
Generating autoload files

And I expected this to happen:

install version 0.5.0, not version 0.0.2

the issue can be reproduced with Docker using the command docker build . in a directory containing this Dockerfile:

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y \
    && apt-get install -y php-cli wget git
RUN wget 'https://getcomposer.org/installer' -O 'composer-setup.php'
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
RUN ./composer.phar -vvv require php81_bc/strftime
RUN ./composer.phar diagnose

However using the alternative Dockerfile

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y \
    && apt-get install -y php-cli git composer
RUN composer require php81_bc/strftime
RUN composer diagnose

will install Ubuntu 20.04's default Composer version, which is currently 1.10.1, and install php81_bc/strftime 0.5.0

@divinity76 divinity76 changed the title defaults to wrong default version on "alphp / strftime" on Ubuntu Linux (but not Windows nor CentOS Linux) defaults to wrong default version on "alphp / strftime" on some systems Jun 19, 2022
@divinity76 divinity76 changed the title defaults to wrong default version on "alphp / strftime" on some systems defaults to wrong default version of "alphp / strftime" on some systems Jun 19, 2022
@divinity76 divinity76 changed the title defaults to wrong default version of "alphp / strftime" on some systems defaults to wrong version of "alphp / strftime" on some systems Jun 19, 2022
@divinity76 divinity76 changed the title defaults to wrong version of "alphp / strftime" on some systems defaults to wrong version of php81_bc/strftime on some systems Jun 19, 2022
@Seldaek
Copy link
Member

Seldaek commented Jun 21, 2022

I'm pretty sure this is not a composer version issue but rather the fact that php81_bc/strftime 0.0.3 and above requires ext-intl. I assume some of your environments do not have the intl extension enabled and those then must select php81_bc/strftime 0.0.2 to be workable.

Solution on your end would be to ensure intl is enabled.

Let's keep this open tho, I believe maybe we can output some hint about this in the require command when the latest version cannot be selected due to some platform constraint, as it's definitely not the first time someone wastes time on this.

@Seldaek Seldaek added this to the 2.4 milestone Jun 21, 2022
Seldaek added a commit that referenced this issue Jun 23, 2022
Seldaek added a commit to Seldaek/composer that referenced this issue Jun 23, 2022
@Seldaek
Copy link
Member

Seldaek commented Jun 23, 2022

See #10896

Seldaek added a commit to Seldaek/composer that referenced this issue Jun 23, 2022
Seldaek added a commit that referenced this issue Jun 23, 2022
emahorvat52 pushed a commit to emahorvat52/composer that referenced this issue Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants