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 require rejects self.version as version constraint #10593

Closed
PhrozenByte opened this issue Mar 6, 2022 · 0 comments
Closed

composer require rejects self.version as version constraint #10593

PhrozenByte opened this issue Mar 6, 2022 · 0 comments
Labels
Milestone

Comments

@PhrozenByte
Copy link

My composer.json:

{"name":"composer/hello-world","version":"1.0.0"}

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.
The version field is present, it is recommended to leave it out if the package is published on Packagist.
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.2.7
PHP version: 7.2.24
PHP binary path: /usr/bin/php7.2
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018
cURL version: 7.58.0 libz 1.2.11 ssl OpenSSL/1.1.1
zip: extension present, unzip present, 7-Zip present (7z)

When I run this command:

composer require -vvv 'psr/log self.version'

I get the following output:

Running 2.2.7 (2022-02-25 11:12:27) with PHP 7.2.24-0ubuntu0.18.04.11 on Linux / 5.4.0-97-generic
Reading ./composer.json (/tmp/tmp.naPyUDx5l9/composer.json)
Loading config file /home/daniel/.config/composer/config.json
Loading config file /home/daniel/.config/composer/auth.json
Loading config file ./composer.json (/tmp/tmp.naPyUDx5l9/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
Failed to initialize global composer: Composer could not find the config file: /home/daniel/.config/composer/composer.json


                                                                                          
  [UnexpectedValueException]                                                              
  Could not parse version constraint self.version: Invalid version string "self.version"  
                                                                                          

Exception trace:
 () at phar:///usr/local/bin/composer2/vendor/composer/semver/src/VersionParser.php:519
 Composer\Semver\VersionParser->parseConstraint() at phar:///usr/local/bin/composer2/vendor/composer/semver/src/VersionParser.php:274
 Composer\Semver\VersionParser->parseConstraints() at phar:///usr/local/bin/composer2/src/Composer/Package/Version/VersionParser.php:34
 Composer\Package\Version\VersionParser->parseConstraints() at phar:///usr/local/bin/composer2/src/Composer/Command/RequireCommand.php:228
 Composer\Command\RequireCommand->execute() at phar:///usr/local/bin/composer2/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer2/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer2/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer2/src/Composer/Console/Application.php:336
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer2/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer2/src/Composer/Console/Application.php:131
 Composer\Console\Application->run() at phar:///usr/local/bin/composer2/bin/composer:83
 require() at /usr/local/bin/composer2:29

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>]...

And I expected this to happen:

self.version is a valid version constraint that works just fine for composer install, composer update, and others. Manually adding {"require":{"psr/log":"self.version"}} to composer.json and running composer update installs psr/log as of v1.0.0, just as expected. self.version is also rejected by composer require --no-update.

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

2 participants