7

I tried to install Magento 2.4 via command line. It runs smooth until

[Progress: 653 / 1206]
Module 'Magento_ComposerRootUpdatePlugin':

At this step the installation fails with

Installing data... Reading /<magento_root>/composer.json
Loading config file /<magento_root>/composer.json
Failed to initialize global composer: Composer could not find the config file: /<magento_root>/var/composer_home/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

Composer is installed globally. The Magento documentation does not mention anything else regarding composer.

Thank you very much.

14
  • Facing the Same Error Failed to initialize global composer: Composer could not find the config file: /Users/mac/sites/ewlicense/var/composer_home/composer.json To initialize a project, please create a composer.json file as described in the getcomposer.org "Getting Started" section I also tried composer self-update but it still not fixed the issue. the Url is giving me 502 Bag Gateway Aug 3, 2020 at 13:27
  • I'm facing the same issue...
    – KaMZaTa
    Aug 4, 2020 at 0:10
  • @hardy123480 Were you able to install Magento 2.4.0 even if it's shown this error?
    – KaMZaTa
    Aug 4, 2020 at 12:52
  • 1
    Kind of. What I now tried is to install a local instance of composer in the Magnet root directory. It still throws the error but the installation goes through successfully. Unfortunately, I get 502 Bad Gateway if I want to access the frontend / backend. I'm running out of ideas. Aug 4, 2020 at 13:11
  • @hardy123480 which php version are you running? 7.4.8?
    – KaMZaTa
    Aug 4, 2020 at 15:26

4 Answers 4

11

Here's a workaround - after creating the project from magento Repo, create the composer.json file

cd var
mkdir composer_home
cd composer_home
vim composer.json

composer.json contents-

{
}

Hope this works for you

1
  • has you installed custom modules via composer in vendor source path ? and installed or register in magento ?
    – Adrian R
    Jul 7, 2021 at 21:08
3

I had the same problem. But it was solved by creating auth.json in var/composer_home like this

{
   "http-basic": {
      "repo.magento.com": {
         "username": "your username key",
         "password": "your password key"
      }
   }
}
1
0

@Gabriela

it works for me...but command prompt says

"Failed to initialize global composer: Composer could not find the config file: C:/xampp/htdocs/magento/var/composer_home/composer.json"

should i create composer.json instead of auth.json and add your mentioned code.

also please mention, which username and password should i add.

many thanks, rakshith

0

Installed 2.4 ok but got this same error running setup:upgrade. 2.4.x requires composer v2.

Run composer self-update --2 from appropriate account and issue should go away. If you get permission denied and can't elevate then your hosting company will need to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.