netz98 / n98-magerun2

The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work time. All commands are extendable by a module API.
https://magerun.net
Other
870 stars 220 forks source link

Magento Core Commands cannot be loaded. Please verify if "bin/magento" is running #1164

Closed xtremevision closed 1 year ago

xtremevision commented 1 year ago

Describe the bug

After upgrading Magento to 2.4.6 I am getting this error: Magento Core Commands cannot be loaded. Please verify if "bin/magento" is running. Only n98-magerun2 commands are available until the issue is fixed.

Expected behaviour

No errors shown, all command available.

Steps to reproduce the issue

Execute: php81 n98-magerun2.phar (or php82)

Technical details

Centos 7 x64, php81 or php82 n98-magerun2 7.0.1

xtremevision commented 1 year ago

A second test showing this seems to be a problem with the new version, 7.0.1. A different site, Magento 2.4.3-p2, older version works fine, new version after update throws error. See below.

[root@localhost htdocs]# php74 n98-magerun2.phar sys:info

Magento System Information

+--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | name | value | +--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Name | Magento | | Version | 2.4.3-p2 | | Edition | Community | | Root | /home/**/htdocs | | Application Mode | developer | | Session | db | | Crypt Key | d5b14ca641f746b703ea313e143cd240 | | Install Date | Mon, 27 Jan 2020 17:07:56 +0000 | | Search Engine | elasticsearch7 | | Cache Backend | Magento\Framework\Cache\Backend\Redis | | Vendors | Magento, ***** | | Module Count | 335 | | Attribute Count | 316 | | Customer Count | 67309 | | Category Count | 421 | | Product Count | 52648 | | Admin User Count | 3 | | Composer Lock File | found | | Composer Package Count | 641 | | Magento Composer Root Update Plugin | installed | | Magento Composer Dependency Version Audit Plugin | installed | | Magento Coding Standard Package | not installed | | Magento Functional Testing Framework | installed | | MSI Packages | installed | | Sample Data Packages | not installed | | Hyva Default Theme | not installed | | Hyva Theme Module | not installed | +--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ [root@localhost htdocs]# php74 n98-magerun2.phar self-update Updating to version 7.0.1. [======================>-----] 4618028 of 5772529 bytes downloaded

RECENT CHANGES

7.0.1

7.0.0


Successfully updated n98-magerun2

[root@localhost htdocs]# php74 n98-magerun2.phar sys:info Magento Core Commands cannot be loaded. Please verify if "bin/magento" is running. Only n98-magerun2 commands are available until the issue is fixed.

Magento System Information

+--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | name | value | +--------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Name | Magento | | Version | 2.4.3-p2 |

xtremevision commented 1 year ago

I cloned the repo and did a build using php 7.4.33. Copied the newly phar to the Magento instance and it runs without throwing that error.

cmuench commented 1 year ago

@xtremevision Thanks for your analysis. Sadly I cannot reproduce the error in my devbox. The phar works with PHP 8.1 and PHP 8.2 there. One difference between 7.0.0 and 7.0.1 is that we use the same interpreter to call the Magento commands. In the old version the bin/magento commands were started with the standard PHP of your system which is not what we want.

You mentioned that the issue is fixed if the phar is compiled with PHP 7.4. We currently build the phar file with PHP 8.0.12 in a build pipeline. I will check if this could be the problem.

cmuench commented 1 year ago

@xtremevision I changed the PHP version in the phar deployment. The development version is now generated with PHP 7.4. You try again with the development version?

https://files.magerun.net/n98-magerun2-dev.phar

xtremevision commented 1 year ago

Hi Christian,

I have not tried compiling with php 8.x, but I experienced the same problem again last night on another website. I had to recompile on that machine in order to get it to work. I do not know why this is happening. It's the first time I've seen this error/behavior and I've used n98magerun[2] for donkeys years.

I will update you if I find anything else.

Thanks,

Michael.

On 30/03/2023 11:42, Christian Münch wrote:

@xtremevision https://github.com/xtremevision Thanks for your analysis. Sadly I cannot reproduce the error in my devbox. The phar works with PHP 8.1 and PHP 8.2 there. One difference between 7.0.0 and 7.0.1 is that we use the same interpreter to call the Magento commands. In the old version the bin/magento commands were started with the standard PHP of your system which is not what we want.

You mentioned that the issue is fixed if the phar is compiled with PHP 7.4. We currently build the phar file with PHP 8.0.12 in a build pipeline. I will check if this could be the problem.

— Reply to this email directly, view it on GitHub https://github.com/netz98/n98-magerun2/issues/1164#issuecomment-1490525629, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABR3CETRX7NCEMKUUOQ3OFDW6WSUXANCNFSM6AAAAAAWLFQVJE. You are receiving this because you were mentioned.Message ID: @.***>

--

Michael Mussulis

CEO

Xtreme Vision Systems SRL

Reg Com: J40/23/03.01.2012

CUI: 29505826

mobilePhone

+ 40 721 052 013 <tel:+%201%20772%20418%203463>

mobilePhone

+ 1 772 418 3463 <tel:+%201%20772%20418%203463>

emailAddress

***@***.*** ***@***.***>

website

https://xtreme-vision.net <https://xtreme-vision.net>
cmuench commented 1 year ago

@xtremevision Older Magerun version were compiled with PHP 7.4. I updated the PHP version of the deployment server. This changes are now reverted. The development phar is now build with PHP 7.4. Would be good to know if this phar file works in your environment, now. If this solves the issue then I will publish a new v7.0.2 so that some automations can update to this phar file.

xtremevision commented 1 year ago

Yes, it's working. I deleted my compiled version and downloaded latest from: wget https://files.magerun.net/n98-magerun2.phar thanks for the fix.

I think it would be good for you to make a small change, increase the version to 7.0.2 and let me do a "self-update" to see if it breaks or not.

Thanks,

Michael.

On 30/03/2023 12:01, Christian Münch wrote:

@xtremevision https://github.com/xtremevision Older Magerun version were compiled with PHP 7.4. I updated the PHP version of the deployment server. This changes are now reverted. The development phar is now build with PHP 7.4. Would be good to know if this phar file works in your environment, now.

— Reply to this email directly, view it on GitHub https://github.com/netz98/n98-magerun2/issues/1164#issuecomment-1490553352, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABR3CER554HJHH7ZQBVZV5TW6WU4DANCNFSM6AAAAAAWLFQVJE. You are receiving this because you were mentioned.Message ID: @.***>

--

Michael Mussulis

CEO

Xtreme Vision Systems SRL

Reg Com: J40/23/03.01.2012

CUI: 29505826

mobilePhone

+ 40 721 052 013 <tel:+%201%20772%20418%203463>

mobilePhone

+ 1 772 418 3463 <tel:+%201%20772%20418%203463>

emailAddress

***@***.*** ***@***.***>

website

https://xtreme-vision.net <https://xtreme-vision.net>
cmuench commented 1 year ago

New version 7.0.2 is deployed. Thanks. https://magerun.net/n98-magerun2-v7-0-2-bugfix-release/

I close the issue.

xtremevision commented 1 year ago

I am sorry, but it's still happening. I released a site to a new vps, and after doing a self-update I am getting the same error :(

On 30/03/2023 14:09, Christian Münch wrote:

Closed #1164 https://github.com/netz98/n98-magerun2/issues/1164 as completed.

— Reply to this email directly, view it on GitHub https://github.com/netz98/n98-magerun2/issues/1164#event-8890463738, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABR3CEVEWBNR6DWFE7W6CT3W6XD67ANCNFSM6AAAAAAWLFQVJE. You are receiving this because you were mentioned.Message ID: @.***>

--

Michael Mussulis

CEO

Xtreme Vision Systems SRL

Reg Com: J40/23/03.01.2012

CUI: 29505826

mobilePhone

+ 40 721 052 013 <tel:+%201%20772%20418%203463>

mobilePhone

+ 1 772 418 3463 <tel:+%201%20772%20418%203463>

emailAddress

***@***.*** ***@***.***>

website

https://xtreme-vision.net <https://xtreme-vision.net>
cmuench commented 1 year ago

@xtremevision Can you check if your bin/magento is executable?

taoufiqaitali commented 1 year ago

still happen in latest version image

cmuench commented 1 year ago

@xtremevision I see that you run the tool with a relative path. I will check if this can cause the issue.

cmuench commented 1 year ago

@xtremevision I was able to reproduce the issue. It's happening if the default PHP version is e.g. 7.4 but Magento requires at least PHP 8.1. In n98-magerun2 >7.0.0 we load the command list by calling the bin/magento script and let it return a JSON feed of the command. If you specify the PHP version the command list is currently not loaded via the specified PHP interpreter. I wil provide a fix for that.

cmuench commented 1 year ago

@xtremevision I should have fixed the issue. You can test the fix by updating to the development version via n98-magerun2.phar self-update --unstable. I will release the fix with the upcoming 7.1.0 release (maybe next week).

xtremevision commented 1 year ago

[root@]# php81 -v PHP 8.1.14 (cli) (built: Jan  4 2023 06:45:14) (NTS gcc x86_64) Copyright (c) The PHP Group Zend Engine v4.1.14, Copyright (c) Zend Technologies     with Zend OPcache v8.1.14, Copyright (c), by Zend Technologies

On 09/04/2023 08:07, Christian Münch wrote:

@xtremevision https://github.com/xtremevision I was able to reproduce the issue. It's happening if the default PHP version is e.g. 7.4 but Magento requires at least PHP 8.1. In n98-magerun2 >7.0.0 we load the command list by calling the bin/magento script and let it return a JSON feed of the command. If you specify the PHP version the command list is currently not loaded via the specified PHP interpreter. I wil provide a fix for that.

— Reply to this email directly, view it on GitHub https://github.com/netz98/n98-magerun2/issues/1164#issuecomment-1501114197, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABR3CEQJI3CH7GJNOWS5C6LXAKRABANCNFSM6AAAAAAWLFQVJE. You are receiving this because you were mentioned.Message ID: @.***>

--

Michael Mussulis

CEO

Xtreme Vision Systems SRL

Reg Com: J40/23/03.01.2012

CUI: 29505826

mobilePhone

+ 40 721 052 013 <tel:+%201%20772%20418%203463>

mobilePhone

+ 1 772 418 3463 <tel:+%201%20772%20418%203463>

emailAddress

***@***.*** ***@***.***>

website

https://xtreme-vision.net <https://xtreme-vision.net>
xtremevision commented 1 year ago

[root@]# php74 -v PHP 7.4.33 (cli) (built: Nov  9 2022 08:01:02) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies     with the ionCube PHP Loader + ionCube24 v11.0.1, Copyright (c) 2002-2022, by ionCube Ltd.     with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

On 09/04/2023 08:07, Christian Münch wrote:

@xtremevision https://github.com/xtremevision I was able to reproduce the issue. It's happening if the default PHP version is e.g. 7.4 but Magento requires at least PHP 8.1. In n98-magerun2 >7.0.0 we load the command list by calling the bin/magento script and let it return a JSON feed of the command. If you specify the PHP version the command list is currently not loaded via the specified PHP interpreter. I wil provide a fix for that.

— Reply to this email directly, view it on GitHub https://github.com/netz98/n98-magerun2/issues/1164#issuecomment-1501114197, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABR3CEQJI3CH7GJNOWS5C6LXAKRABANCNFSM6AAAAAAWLFQVJE. You are receiving this because you were mentioned.Message ID: @.***>

--

Michael Mussulis

CEO

Xtreme Vision Systems SRL

Reg Com: J40/23/03.01.2012

CUI: 29505826

mobilePhone

+ 40 721 052 013 <tel:+%201%20772%20418%203463>

mobilePhone

+ 1 772 418 3463 <tel:+%201%20772%20418%203463>

emailAddress

***@***.*** ***@***.***>

website

https://xtreme-vision.net <https://xtreme-vision.net>
xtremevision commented 1 year ago

Confirmed fix on both counts. Good work! :)

On 09/04/2023 08:31, Christian Münch wrote:

@xtremevision https://github.com/xtremevision I should have fixed the issue. You can test the fix by updating to the development version via |n98-magerun2.phar self-update --unstable|.

— Reply to this email directly, view it on GitHub https://github.com/netz98/n98-magerun2/issues/1164#issuecomment-1501119130, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABR3CEQ7Y5BY4HX743626MTXAKT2NANCNFSM6AAAAAAWLFQVJE. You are receiving this because you were mentioned.Message ID: @.***>

--

Michael Mussulis

CEO

Xtreme Vision Systems SRL

Reg Com: J40/23/03.01.2012

CUI: 29505826

mobilePhone

+ 40 721 052 013 <tel:+%201%20772%20418%203463>

mobilePhone

+ 1 772 418 3463 <tel:+%201%20772%20418%203463>

emailAddress

***@***.*** ***@***.***>

website

https://xtreme-vision.net <https://xtreme-vision.net>
cmuench commented 1 year ago

@xtremevision I just deployed the fix with 7.0.3.

taoufiqaitali commented 1 year ago

@cmuench still not work for me for dev and 7.0.3 version

image image

cmuench commented 1 year ago

@taoufiqaitali Wow. That's strange. Maybe is the check via --version not good enough. Internally we run php8.1 bin/magento list --format=json. Is that working?

cmuench commented 1 year ago

@taoufiqaitali I see that we catch an exception. I will add the exception message to the output.

taoufiqaitali commented 1 year ago

@cmuench yes yes it work now, i notice that it require to run mysql if not running it will not work because bin/magento list show an error after the list

cmuench commented 1 year ago

@taoufiqaitali ok

simpa407 commented 1 year ago

I got this error when debugging image I use magento 2.3.4-p4, php 7.4 and n98 7.0.3 version. I try updating n98 to 7.1.0.dev but it's same error image Thanks

cmuench commented 1 year ago

@simpa407 I just installed a Magento 2.4.3 and tried the current n98-magerun2 version with PHP 7.4. Sadly I cannot see any error on my machine. Can you run bin/magento in your installation?

simpa407 commented 1 year ago

@cmuench Yes, everything works fine. Just show error when I debug function on cron

cmuench commented 1 year ago

@simpa407 ok. Interesting. This means the error is gone if xdebug is off?

epolish commented 1 year ago

Hi guys. The issue might be here vendor/symfony/process/Process.php @proc_open It passes all ENV vars to the new process (bin/magento --format="json"), and xdebug can't catch that new one and that's why it stucks for 60 seconds Maybe it would be nice idea to filter out the XDEBUG_CONFIG env param in that method

epolish commented 1 year ago

Currently I mage a harcode breakpoint image

cmuench commented 1 year ago

@epolish Thanks for the insights. :-) Let's see if we can fix that.