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 create-project Fatal type error php 8.0 #9554

Closed
Itach1Uchixa opened this issue Dec 9, 2020 · 7 comments
Closed

composer create-project Fatal type error php 8.0 #9554

Itach1Uchixa opened this issue Dec 9, 2020 · 7 comments

Comments

@Itach1Uchixa
Copy link

My composer.json:
No composer.json

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 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.0.8
PHP version: 8.0.0
PHP binary path: /usr/local/bin/php
OpenSSL version: OpenSSL 1.1.1d  10 Sep 2019
cURL version: 7.64.0 libz 1.2.11 ssl OpenSSL/1.1.1d
zip: extension present, unzip not available

When I run this command:

composer create-project mezzio/mezzio-skeleton

I get the following output:

create-project -vvv mezzio/mezzio-skeleton mezzio
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 as described in the https://getcomposer.org/ "Getting Started" section
Running 2.0.8 (2020-12-03 17:20:38) with PHP 8.0.0 on Linux / 4.19.84-microsoft-standard
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 as described in the https://getcomposer.org/ "Getting Started" section
Creating a "mezzio/mezzio-skeleton" project at "./mezzio"
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/opt/Projects): git branch -a --no-color --no-abbrev -v
Executing command (/opt/Projects): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/opt/Projects): git log --pretty="%H" -n1 HEAD
Executing command (/opt/Projects): hg branch
Executing command (/opt/Projects): fossil branch list
Executing command (/opt/Projects): fossil tag list
Executing command (/opt/Projects): svn info --xml
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 as described in the https://getcomposer.org/ "Getting Started" section
Downloading https://repo.packagist.org/packages.json
[200] https://repo.packagist.org/packages.json
Writing /root/.composer/cache/repo/https---repo.packagist.org/packages.json into cache
Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-mezzio~mezzio-skeleton.json from cache
Downloading https://repo.packagist.org/p2/mezzio/mezzio-skeleton.json if modified
[304] https://repo.packagist.org/p2/mezzio/mezzio-skeleton.json
Installing mezzio/mezzio-skeleton (0.5.3)
As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' may remediate them.
Reading /root/.composer/cache/files/mezzio/mezzio-skeleton/e8e8214e0961ee23519a7cade31387a08b2e21fc.zip from cache
  - Loading mezzio/mezzio-skeleton (0.5.3) from cache
  - Installing mezzio/mezzio-skeleton (0.5.3): Extracting archive
Executing command (CWD): rm -rf '/opt/Projects/mezzio'
Executing command (CWD): rm -rf '/opt/Projects/vendor/composer/7a45e9fa'
Executing command (CWD): rm -rf '/opt/Projects/vendor/composer/'
Executing command (CWD): rm -rf '/opt/Projects/vendor'
Downloading https://packagist.org/downloads/
[201] https://packagist.org/downloads/
Created project in /opt/Projects/mezzio
Reading ./composer.json
Loading config file ./composer.json
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 as described in the https://getcomposer.org/ "Getting Started" section
> pre-update-cmd: App\Composer\OptionalPackages::install
Setup data and cache dir
Setting up optional packages

  Which router you want to use?
  [1] Aura.Router
  [2] FastRoute
  [3] Laminas Router
  Make your selection or type a composer package name and version (FastRoute): 2
  - Adding package mezzio/mezzio-fastroute (^0.1)
PHP Fatal error:  Uncaught TypeError: Composer\Package\Link::__construct(): Argument #3 ($constraint) must be of type Composer\Semver\Constraint\ConstraintInterface, null given, called in /opt/Projects/mezzio/src/Composer/OptionalPackages.php on line 290 and defined in phar:///usr/local/bin/composer/src/Composer/Package/Link.php:80
Stack trace:
#0 /opt/Projects/mezzio/src/Composer/OptionalPackages.php(290): Composer\Package\Link->__construct('__root__', 'mezzio/mezzio-f...', NULL, 'requires', '^0.1')
#1 /opt/Projects/mezzio/src/Composer/OptionalPackages.php(129): App\Composer\OptionalPackages::addPackage(Object(Composer\IO\ConsoleIO), 'mezzio/mezzio-f...', '^0.1')
#2 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(322): App\Composer\OptionalPackages::install(Object(Composer\Script\Event))
#3 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(218): Composer\EventDispatcher\EventDispatcher->executeEventPhpScript('App\\Composer\\Op...', 'install', Object(Composer\Script\Event))
#4 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(101): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Script\Event))
#5 phar:///usr/local/bin/composer/src/Composer/Installer.php(231): Composer\EventDispatcher\EventDispatcher->dispatchScript('pre-update-cmd', true)
#6 phar:///usr/local/bin/composer/src/Composer/Command/CreateProjectCommand.php(241): Composer\Installer->run()
#7 phar:///usr/local/bin/composer/src/Composer/Command/CreateProjectCommand.php(156): Composer\Command\CreateProjectCommand->installProject(Object(Composer\IO\ConsoleIO), Object(Composer\Config), Object(Symfony\Component\Console\Input\ArgvInput), 'mezzio/mezzio-s...', 'mezzio', NULL, NULL, false, false, true, NULL, false, false, false, false, false, true, false)
#8 phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php(245): Composer\Command\CreateProjectCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Composer\Command\CreateProjectCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(310): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 phar:///usr/local/bin/composer/bin/composer(63): Composer\Console\Application->run()
#15 /usr/local/bin/composer(24): require('phar:///usr/loc...')
#16 {main}
  thrown in phar:///usr/local/bin/composer/src/Composer/Package/Link.php on line 80

Fatal error: Uncaught TypeError: Composer\Package\Link::__construct(): Argument #3 ($constraint) must be of type Composer\Semver\Constraint\ConstraintInterface, null given, called in /opt/Projects/mezzio/src/Composer/OptionalPackages.php on line 290 and defined in phar:///usr/local/bin/composer/src/Composer/Package/Link.php:80
Stack trace:
#0 /opt/Projects/mezzio/src/Composer/OptionalPackages.php(290): Composer\Package\Link->__construct('__root__', 'mezzio/mezzio-f...', NULL, 'requires', '^0.1')
#1 /opt/Projects/mezzio/src/Composer/OptionalPackages.php(129): App\Composer\OptionalPackages::addPackage(Object(Composer\IO\ConsoleIO), 'mezzio/mezzio-f...', '^0.1')
#2 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(322): App\Composer\OptionalPackages::install(Object(Composer\Script\Event))
#3 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(218): Composer\EventDispatcher\EventDispatcher->executeEventPhpScript('App\\Composer\\Op...', 'install', Object(Composer\Script\Event))
#4 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(101): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Script\Event))
#5 phar:///usr/local/bin/composer/src/Composer/Installer.php(231): Composer\EventDispatcher\EventDispatcher->dispatchScript('pre-update-cmd', true)
#6 phar:///usr/local/bin/composer/src/Composer/Command/CreateProjectCommand.php(241): Composer\Installer->run()
#7 phar:///usr/local/bin/composer/src/Composer/Command/CreateProjectCommand.php(156): Composer\Command\CreateProjectCommand->installProject(Object(Composer\IO\ConsoleIO), Object(Composer\Config), Object(Symfony\Component\Console\Input\ArgvInput), 'mezzio/mezzio-s...', 'mezzio', NULL, NULL, false, false, true, NULL, false, false, false, false, false, true, false)
#8 phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php(245): Composer\Command\CreateProjectCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Composer\Command\CreateProjectCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(310): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 phar:///usr/local/bin/composer/bin/composer(63): Composer\Console\Application->run()
#15 /usr/local/bin/composer(24): require('phar:///usr/loc...')
#16 {main}
  thrown in phar:///usr/local/bin/composer/src/Composer/Package/Link.php on line 80

And I expected this to happen:
New project creation

@Itach1Uchixa Itach1Uchixa changed the title Composer create project type error same as #9252, #9265 Composer php 8.0 create project type error Dec 9, 2020
@Itach1Uchixa
Copy link
Author

Exception are same with: #9265 and #9252

@Itach1Uchixa Itach1Uchixa changed the title Composer php 8.0 create project type error composer create-project Fatal type error php 8.0 Dec 9, 2020
@Seldaek
Copy link
Member

Seldaek commented Dec 10, 2020

The issue is you're using a very old mezzio/mezzio-skeleton (0.5.3). If you force the version to a new one like composer create-project -vvv mezzio/mezzio-skeleton:^3 mezzio then it should work.

The issue seems to be that you're using PHP 8 and the new versions of mezzio-skeleton only support 7.1, while this old 0.5.3 had no php constraint so it is chosen as the default version.

Running the command with ^3 constraint shows the root cause:

[InvalidArgumentException]
Could not find package mezzio/mezzio-skeleton with version ^3 in a version installable using your PHP version, PHP extensions and Composer version.

See mezzio/mezzio-skeleton#38

@Seldaek Seldaek closed this as completed Dec 10, 2020
@Seldaek
Copy link
Member

Seldaek commented Dec 10, 2020

@weierophinney it might be good to delete the 0.x tags from github and packagist.org for this package. According to the stats it seems like pretty much nobody is using them https://packagist.org/packages/mezzio/mezzio-skeleton/stats - except a few lost souls in the last few weeks which I assume were all using PHP 8.

@weierophinney
Copy link
Contributor

@Seldaek do we need to delete the tags, or just the releases on Packagist? (i.e., if we delete the release on packagist, is it going to re-populate the version later because the release exists on GitHub, or does it stay removed from Packagist at that point?)

@Seldaek
Copy link
Member

Seldaek commented Dec 10, 2020

@weierophinney you'll have to delete the tags otherwise they come back on the next packagist update yes.

@Itach1Uchixa
Copy link
Author

@Seldaek Thank you, I appreciate your time. It just I thought that php 8 was causing this issue.

@weierophinney
Copy link
Contributor

I've deleted all pre-1.0.0 tags from the GitHub repo, and removed them from Packagist as well; hopefully this resolves the issues reported!

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

No branches or pull requests

3 participants