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

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

Closed
xtremevision opened this issue Mar 28, 2023 · 30 comments · Fixed by #1178
Closed
Assignees
Labels

Comments

@xtremevision
Copy link

xtremevision commented Mar 28, 2023

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
Copy link
Author

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

  • Add: Magento 2.4.6
  • Add: Magento 2.4.5-p2
  • Add: Magento 2.4.4-p2
  • Add: New command config:data:indexer #1041: New command config:data:indexer (by Christian Münch)
  • Add: New command config:data:mview #1042: New command config:data:mview (by Christian Münch)
  • Add: Add CONTRIBUTING.md and CODE_OF_CONDUCT.md #1126: Add CONTRIBUTING.md and CODE_OF_CONDUCT.md (by Christian Münch)
  • Imp: Make detection debug output more helpful #1123: Make detection debug output more helpful (by Alexander Menk)
  • Imp: New internal proxy command to call Magento Core Commands (by Christian Münch)
  • Imp: Disabled Magento and config initialization if self-update command runs (by Christian Münch)
  • Imp: Update 3rd party dependencies (Symfony, psysh, captainhook, php-cs-fixer, phpunit, twig)
  • Del: Support for PHP 7.3
  • Del: Remove internal test setup for Composer 1 based Magento installations
  • Fix: Initialize Magento only once which should prevent several issues with DB and config. (by Christian Münch)
  • Fix: Remove "please select" entry in search:engine:list command (by Christian Münch)

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
Copy link
Author

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
Copy link
Member

cmuench commented Mar 30, 2023

@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
Copy link
Member

cmuench commented Mar 30, 2023

@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
Copy link
Author

xtremevision commented Mar 30, 2023 via email

@cmuench
Copy link
Member

cmuench commented Mar 30, 2023

@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
Copy link
Author

xtremevision commented Mar 30, 2023 via email

@cmuench
Copy link
Member

cmuench commented Mar 30, 2023

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

I close the issue.

@cmuench cmuench closed this as completed Mar 30, 2023
@xtremevision
Copy link
Author

xtremevision commented Apr 6, 2023 via email

@cmuench
Copy link
Member

cmuench commented Apr 7, 2023

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

@taoufiqaitali
Copy link

still happen in latest version
image

@cmuench cmuench reopened this Apr 9, 2023
@cmuench
Copy link
Member

cmuench commented Apr 9, 2023

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

@cmuench
Copy link
Member

cmuench commented Apr 9, 2023

@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
Copy link
Member

cmuench commented Apr 9, 2023

@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
Copy link
Author

xtremevision commented Apr 9, 2023 via email

@xtremevision
Copy link
Author

xtremevision commented Apr 9, 2023 via email

@xtremevision
Copy link
Author

xtremevision commented Apr 9, 2023 via email

@cmuench
Copy link
Member

cmuench commented Apr 11, 2023

@xtremevision I just deployed the fix with 7.0.3.

@taoufiqaitali
Copy link

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

image
image

@cmuench
Copy link
Member

cmuench commented Apr 11, 2023

@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
Copy link
Member

cmuench commented Apr 11, 2023

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

@taoufiqaitali
Copy link

taoufiqaitali commented Apr 11, 2023

@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
Copy link
Member

cmuench commented Apr 11, 2023

@taoufiqaitali ok

cmuench added a commit to cmuench/n98-magerun2 that referenced this issue Apr 11, 2023
cmuench added a commit that referenced this issue Apr 11, 2023
@simpa407
Copy link

simpa407 commented Jun 5, 2023

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
Copy link
Member

cmuench commented Jun 5, 2023

@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
Copy link

simpa407 commented Jun 6, 2023

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

@cmuench
Copy link
Member

cmuench commented Jun 6, 2023

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

@epolish
Copy link

epolish commented Jul 10, 2023

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
Copy link

epolish commented Jul 10, 2023

Currently I mage a harcode breakpoint
image

@cmuench
Copy link
Member

cmuench commented Jul 10, 2023

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

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

Successfully merging a pull request may close this issue.

5 participants