magento2: Blank install of Magento 2.4.1 via composer breaks on setup:install command.

Preconditions (*)

  1. PHP - 7.4.9
  2. Apache 2.4

Steps to reproduce (*)

  1. Run Composer Command composer create-project --repository=https://repo.magento.com/ magento/project-community-edition magento2
  2. Attempt to run command-line installation. php bin/magento setup:install --base-url=http://241.loc/ --db-host=mysql --db-name=241 --db-user=root --db-password= --admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1 --search-engine=elasticsearch7 --elasticsearch-host=elastic --elasticsearch-port=9200

Expected result (*)

  1. Magento Installs

Actual result (*)

  1. Fatal Error Fatal error: Declaration of Psr\Log\LoggerInterface\Proxy::emergency($message, array $context) must be compatible with Psr\Log\LoggerInterface::emergency($message, array $context = NULL) in /shared/httpd/24/htdocs/magento2/generated/code/Psr/Log/LoggerInterface/Proxy.php on line 93 The proxy generated has functions like below:

public function alert($message, array $context)

However, if you change them directly to:

public function alert($message, array $context = array())


The command will then run successfully, however it will break all bin/magento setup:xxx commands the next time the code is regenerated.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 74 (51 by maintainers)

Most upvoted comments

@pusachev @ihor-sviziev I bumped into this same issue and was able to solve it by removing the PSR extension (Ubuntu with PHP 7.3: apt-get remove php7.3-psr).

However, the question of @pusachev intrigued me: Why is the proxy needed in the first place?

I tried it and this gave the error Circular dependency: Magento\Framework\Logger\Monolog depends on Magento\Framework\Interception\PluginListGenerator. In other words, the reason why a DI proxy is needed is to fix the circular dependency at constructor time, while at the moment a method of PluginListGenerator is called where logging is needed, this issue is fixed already. So, there is no (easy) way to remove the proxy itself.

@zenfork and any others using Devilbox running into this issue, I can confirm disabling the psr extension solves the issue.

You’ll need to edit the entry to add “psr” in the .env of your devilbox root.

PHP_MODULES_DISABLE=oci8,PDO_OCI,pdo_sqlsrv,sqlsrv,rdkafka,swoole,psr,phalcon

Hey. I have a question. Why we need create proxy for LoggerInterface object? What this profit we have from this “optimization”?

Maybe make sense remove proxy from DI class and this is fix problem in install.

@gabrieldagama, @sdzhepa: this is really bad behavior of the bot, I’ve seen this happening a few times before in other tickets. Placing automated comments like these put people at ease, they believe that an issue will actually be fixed if a bot leaves this comment even if we can’t find a reference to it in the commits (because we’ve grown accustomed by now that publishing code to github can sometimes take a few days or weeks even if a ticket is already closed before that happens).

Can you investigate this bot and fix it so it doesn’t leave incorrect comments like these anymore in the future?

Thanks!

@sidolov @sivaschenko @gabrieldagama i don’t see any commits related to internal ticket if using search https://github.com/magento/magento2/search?q=MC-38918&type=commits . Could you please provide us some info how we can find the fix ?

@hostep good point, but I hope it will be fixed on the php extension side soon, so it will not be correct. Let’s wait at least for some response. PS: issue already reported https://github.com/jbboehr/php-psr/issues/78

@textarea I see you have installed psr pecl extension. I believe it might cause such issues. Could you try to remove/disable it, remove all files from generated/code/ folder and try again?

Interesting… files vendor/psr/log/Psr/Log/LoggerInterface.php are equal, but in your generated/code/Psr/Log/LoggerInterface/Proxy.php we have

    /**
     * {@inheritdoc}
     */
    public function emergency($message, array $context)
    {
        return $this->_getSubject()->emergency($message, $context);
    }

while in my I have

    /**
     * {@inheritdoc}
     */
    public function emergency($message, array $context = [])
    {
        return $this->_getSubject()->emergency($message, $context);
    }

Default value is not defined. Checking…

I guess, for me that was a file permissions problem. These steps help me, when I upgrading from 2.4.0 to 2.4.1:

  1. Go to Magento 2 folder
  2. sudo chown -R :apache . (for Devilbox I used my user as owner - sudo chown -R 1000:1000 .)
  3. rm -rf generated/code/*

UPD: No, that ^ worked when I up project on the Magento Docker. But when I back to the Devilbox LAMP stack again (PHP 7.3.23 and 7.4.11) - error still persists. It seems to be an environment problem

Hi @msyhr. Thank you for your report. To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

There was nothing I could do (module:enable etc.) due to this error. I add to \Magento\Framework\Code\Generator\EntityAbstract::extractParameterDefaultValue before return $value this code if($this->getSourceClassName() === '\Psr\Log\LoggerInterface' && $parameter->name === 'context') {$value = new ValueGenerator(array(), ValueGenerator::TYPE_ARRAY);}

Hi @ihor-sviziev, I was able to set the project and run commands after disabling php psr module. I will check & update about codesiffer & code beautifier tool output !

Thanks @ihor-sviziev

@ihor-sviziev Even if it is fixed on the extension level, there will be instances that could not/will not upgrade that easily. Could we at least update documentation (https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements-tech.html) and add another note that “specific version XX.XX of extension PSR can caused issue”?

@ihor-sviziev yes it works after psr pecl remove. Also for me now phalcon has to be removed 😉 Thanks!

@ihor-sviziev I followed your advice and removed the PSR extension. It worked! I checked with my docker container and it doesn’t have it installed. So it makes sense why it was working there but not on the environment without docker. I had the extension installed because I also have Phalcon based site on that machine too. Thanks! … now I have to remove Phalcon 😄

@ihor-sviziev magento full code in https://we.tl/t-I5WRn8yUvM, php -i info in attached phpinfo.txt and php version in attached phpversion.txt phpinfo.txt phpversion.txt

Hi @ihor-sviziev here are mines Archive.zip

I have same issue on after upgrading Magento Cloud 2.3.6 to 2.4.1 version with PHP 7.3.23. This error happens on setup:upgrade and any other commands of bin/magento

$ php -v
PHP 7.3.23 (cli) (built: Oct 13 2020 10:38:39) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.23, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.23, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
    with blackfire v1.42.0~linux-x64-non_zts73, https://blackfire.io, by Blackfire

UPD: After downgrade Magento to 2.4.0 this error didn’t show anymore. I’m using Docker LAMP stack “Devilbox”