magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.59k stars 9.32k forks source link

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

Closed msyhr closed 4 years ago

msyhr commented 4 years ago

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.

ihor-sviziev commented 4 years ago

@krisdass I think it shouldn't be required, but definitely let us know if it is

hostep commented 4 years ago

@ihor-sviziev : since this was reported by many people, I think we need to do something properly about this.

Could we maybe add the following to the composer.json file?

    "conflict": {
        "ext-psr": "*"
    },
ihor-sviziev commented 4 years ago

@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

denchev commented 4 years ago

@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"?

krisdass commented 4 years ago

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

magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @ihor-sviziev Thank you for verifying the issue. Based on the provided information internal tickets MC-38918 were created

Issue Available: @ihor-sviziev, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

ihor-sviziev commented 4 years ago

I created PR for updating docs in order to highlight that psr php extension might cause such issues. https://github.com/magento/devdocs/pull/8185

m2-assistant[bot] commented 4 years ago

Hi @ihor-sviziev. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


ihor-sviziev commented 4 years ago

Ok... we got responce from the author of psr extension, seems like PHP 7 API isn't supporting default values, so it can't be fixed for php 7.3 and php 7.4, but could be fixed for php 8.0, and it will be done in https://github.com/jbboehr/php-psr/pull/79.

So currently we have three options:

  1. ✔ Add docs for not using psr php extension with Magento 2 to the docs - I already did in https://github.com/magento/devdocs/pull/8185, hope someone will review it soon
  2. ❔ [not sure] Add conflict with ext-psr to the composer.json file, as suggested in https://github.com/magento/magento2/issues/30575#issuecomment-721813406
  3. ❔ [not sure] Add compatibility with psr extension in the magento2

For now I think adding just a warning to the docs should be enough, I still thinking about implementation of 2nd or maybe 3rd option.

msyhr commented 4 years ago

@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

pusachev commented 4 years ago

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.

ihor-sviziev commented 4 years ago

@pusachev TBH I don't really know. Feel free to investigate it 😃

jakwinkler commented 4 years ago

This issue is also related to an upgrade: 2.3.4 -> 2.4.0 2.3.5 -> 2.4.0 2.3.6 -> 2.4.0 and the same with upgrade to 2.4.1

ihor-sviziev commented 4 years ago

@qsolutions-pl FYI we added info that psr extension causing issue to the docs in https://github.com/magento/devdocs/pull/8185: https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements.html

jissereitsma commented 4 years ago

@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.

ihor-sviziev commented 3 years ago

@jissereitsma I believe the only one valid fix will be introducing some not dynamically created logger proxy with the same logic inside

magento-engcom-team commented 3 years ago

Hi @msyhr, @ihor-sviziev, @engcom-Delta.

Thank you for your report and collaboration!

The related internal Jira ticket MC-38918 was closed as Complete.

The fix will be available with the upcoming 2.4.3 release.

ihor-sviziev commented 3 years ago

@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 ?

gabrieldagama commented 3 years ago

Hi @ihor-sviziev, this issue was manually closed on our Jira Project because the GitHub one was already closed for some time. Apparently, our bot has added the message about the fix, but, there is no fix.

If this still an issue, please feel free to reopen it!

Thanks!

hostep commented 3 years ago

@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!

saharin88 commented 3 years ago

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);}

ahmedch1 commented 3 years ago

I got same error , anyone knows how to solve it? Thanks in advance

ihor-sviziev commented 3 years ago

@ahmedch1 make sure you don't have installed psr php extension. If you have such - please remove it

murtuza1234 commented 3 years ago

@jissereitsma great mate your solution works like charm, a dozen thank you