163

I'm just trying to deploy my application and I just ran composer update on my server and I got the following error:

In PackageManifest.php line 122: Undefined index: name

How can I fix this issue?

arety_
  • 1,983
  • 2
  • 10
  • 23
  • 3
    I had a same issue, but on my local env (docker). I fixed it by using composer update outside docker container, so basically using php and composer installed on my Mac. If you use docker you can try to do the same thing, maybe not the best way how to fix it but it works. :) – SakuragiRokurota Apr 13 '20 at 12:40
  • I tried so many answers below but only https://stackoverflow.com/questions/61177995/laravel-packagemanifest-php-undefined-index-name#comment118778877_65651152 worked for me. – Ryan Apr 21 '21 at 15:02

30 Answers30

238

As a temporary fix, try this, it worked for me, in the following file:

vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php

Find line 116 and comment it:

$packages = json_decode($this->files->get($path), true);

Add two new lines after the above commented line:

$installed = json_decode($this->files->get($path), true);
$packages = $installed['packages'] ?? $installed;
Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116
Pulkit Modi
  • 2,653
  • 2
  • 8
  • 6
203

I had the same problem, I just execute the command:

composer update

this will updated the composer.lock file. After that worked like a charm.

  • 9
    I don't know why people accept downgrading composer or changing the source files of Laravel as a solution, while this is the right way to fix it. – shamaseen Dec 25 '20 at 20:45
  • 6
    @shamaseen because you don't want to run "composer update" on a production environment. – Johan Apr 20 '21 at 06:45
  • 2
    This will update all your library files to their latest version constrained by composer.json. You may or may not want to do this. https://getcomposer.org/doc/03-cli.md#update-u – waterloomatt May 17 '21 at 15:29
  • This should be the accepted answer. Works without editting any files! – Jaytjuh Jun 02 '21 at 07:51
  • This works, the situation is that all dependencies will be updated to the latest version and probably some scripts will break, so take that on consideration. – Héctor William Jul 02 '21 at 18:48
  • 3
    This did not work for me – Jon Winstanley Feb 18 '22 at 19:43
63

I found this issue on the composer GitHub repo that helped a lot

I updated my Laravel framework from 5.8 to 5.8.38, following the table displayed in that issue and the error disappeared.

This Laravel blog post also helps

If you can't upgrade Laravel, you can just stay with Composer 1 by running

composer self-update --1
Salim Djerbouh
  • 10,719
  • 6
  • 29
  • 61
DavidHyogo
  • 2,838
  • 4
  • 31
  • 48
  • 1
    This reply works for me when upgrading Laravel 5.5 to 6.x – Farid Nov 11 '20 at 15:06
  • 1
    Use composer self-update --rollback to return to version 2.0.13 – saber tabatabaee yazdi May 05 '21 at 15:41
  • works for me too – tree em Sep 17 '21 at 06:51
  • 1
    Thank you, your answer fixed the problem but didn't clearly explain why. The actual problem is that the laravel version we're running is not compatible with composer 2.x. Both downgrading composer to 1.x or upgrading to a compatible laravel fix the problem. https://github.com/composer/composer/issues/9340#issuecomment-716210369 – 8ctopus Mar 07 '22 at 12:33
48

I recently switched composer 2.0.8 and my Laravel version is 6.20.27

To solve this issue:

Step 1:

Delete compose.lock File

Step 2:

Install dependencies.

composer install
Bedram Tamang
  • 3,748
  • 31
  • 27
  • This solved it for me too without need to downgrade composer. I think this should be the approved answer. Perhaps downgrading composer also solves it, but in my case and in my opinion it's less ideal to downgrade. – amosmos Jul 06 '21 at 10:23
  • i think this is the same of not deleting the composer.lock file and just run composer update. – kapitan Jul 28 '21 at 02:11
  • @kapitan It is not. `composer update` looks into composer.lock file and updates each dependencies to newer version, if newer version is available. But `composer install` with deleting `composer.lock` file doesn't care what has been previously installed, it installs everything as fresh of `composer.json` file – Bedram Tamang Jul 28 '21 at 08:54
  • 1
    @BedramTamang -I actually knew what's happening on both cases. I am actually talking about the version of the packages that will be installed at the end because both will install the newest package. – kapitan Jul 30 '21 at 06:19
  • 1
    this one should be marked as correct answer. – Jitesh Dhamaniya Oct 18 '21 at 13:36
  • Worked for me too; Laravel 5.8.28. After deleting the composer.lock, all packages were installed successfully. Then checked version, it had upgraded to 5.8.38 – Lawrence Macharia Oct 25 '22 at 05:45
  • This issue appeared when I changed the folder name of the project. And this is the fix that worked for me. Cheers. – Leutecia Dec 18 '22 at 12:28
47

I had the same problem.

In my case downgrading the composer version fixed the problem.

They updated Composer 4 times within 2 days - I think they had a problem with their newest updates.

In my case version 1.10.1 was the version to go with.

sudo composer self-update --1

I hope it'll work.

Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116
epheser
  • 535
  • 5
  • 2
30

I had a problem like this, and also tried composer self-update --stable, but there was no result. So, I found that this file belongs to the Laravel framework. So the following command resolved this issue:

$ composer update laravel/framework

DavidHyogo
  • 2,838
  • 4
  • 31
  • 48
20

In my case downgrading the composer version fixed the problem.

sudo composer self-update --1
Gerardo Argueta
  • 301
  • 2
  • 3
19

https://github.com/composer/composer/issues/9340#issuecomment-716210369

As stated in here, your laravel version may conflict with composer 2

composer update laravel/framework

should fix your problem :D

truongnm
  • 2,311
  • 2
  • 31
  • 48
  • 1
    Thank you!!! I must have updated to Composer 2 at some point but was still running Laravel 6.0 in this repo. I needed to do a LOT of manual upgrades to get this working. But what you pointed to was definitely my problem. Thanks. – Ryan Apr 21 '21 at 15:02
11

The easiest way to solve this issue is

delete composer.lock file from your project.

Run composer install

Sk Shoyeb
  • 147
  • 1
  • 3
9

I was facing the same issue. I Saw my Laravel framework version is "laravel/framework": "6.0" So just put the cap before the version and it starts working fine. "laravel/framework": "^6.0"

Abrar Ahmad
  • 330
  • 8
  • 15
  • 2
    Looks like there may be a few different causes of this issue, each with different solutions, but this was what worked for me. In context, upgrading from 5.8 where every .1 is a major version change, but on 6+ every .1 is a minor version. So locking to "6.0" or "6.0.*" kept it on "6.0.4" and avoided the rest of the version updates (currently "6.20.16") This bug existed on "6.0.4" but was fixed after. – Mark Walker Feb 15 '21 at 01:56
  • 1
    I also faced the same issue but couldn't fix it by applying almost all solutions listed here. However, this solution triggered something in me and I checked my framework version once again and found that it was entered wrongly(I was testing something on the previous day). I put the right framework number and the issues got disappeared instantly. Thank You! – Aromal Pillai Jan 31 '22 at 06:07
8

Running the following command worked for me. Maybe this will help someone needy.

composer update
Satendra Rawat
  • 1,264
  • 11
  • 23
8

I removed my vendor folder and composer.lock and ran composer install again. This solved it for me.

Jos Koomen
  • 372
  • 1
  • 3
  • 15
6

Some versions of composer give this error, the version 1.10.20 doesn't throw this error

composer self-update 1.10.20
composer install
Ashiq KS
  • 145
  • 2
  • 9
5

Running composer update worked for my project with Laravel 5.7

Joundill
  • 6,828
  • 12
  • 36
  • 50
Gandhist
  • 89
  • 1
  • 2
  • 3
    This may be the correct answer but another user has already posted something similar. When writing a new answer please try to include additional information or examples that the other answers don't have. – sorifiend Feb 04 '21 at 04:25
3

For my Laravel 5.7 project deleting vendor folder and composer.lock file fixed the issue.

Nabil
  • 33
  • 1
  • 5
3

I have a solution:

  • Delete the vendor folder.
  • run composer install

Don't use --no-scripts. This will cause a problem, and will not create the appropiate folders which the file PackageManifest.php and others need.

  • run composer update

This is so you don't have problems with bugs in the file.

SherylHohman
  • 16,580
  • 17
  • 88
  • 94
Martin Muñoz
  • 436
  • 4
  • 6
3

Try this, it is worked for me, in the following file:

vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php

Find this line and comment on it

$packages = json_decode($this->files->get($path), true);

Add two new lines after the above-commented line

$installed = json_decode($this->files->get($path), true);
$packages = $installed['packages'] ?? $installed;
3

If you want to fix without making updates and composer updates

just go to vendor/composer and remove installed.json

Burhan Ibrahimi
  • 367
  • 3
  • 14
2

Running the following command fixed it for us

composer self-update --stable
Nick Zinger
  • 1,174
  • 1
  • 12
  • 28
  • 2
    This didn't work for me. I got the message `You are already using composer version 2.0.4 (stable channel).` – DavidHyogo Nov 04 '20 at 12:00
2

No need to force an upgrade on your packages (running composer update on production is not recommended anyway) or downgrade your Composer if it's on version 2.

If you have a website that requires Composer v1 for updates (because, for example, v2 causes errors) and you have version v2 installed globally, the quickest solution is:

Step 1

Download the latest stable 1.x composer.phar from https://getcomposer.org/download/ (under Manual Download).

Step 2

Place the downloaded composer.phar file in the root of your project (where the composer.json file resides).

Step 3

Run your command using the composer.phar file. Example:

php composer.phar install
ChimeraTheory
  • 493
  • 1
  • 4
  • 11
1

To downgrade composer to an old version:

composer self-update <version>

Example:

composer self-update 1.10.1 
Prograymer
  • 11
  • 1
1

I updated to Composer 2.0.11 and I had the error. Downgraded to Composer 1.10.20, it worked great, BUT IT'S VERY VERY SLOW.

So for those like me who don't want to change the vendor code, and still want Composer 2.0.x know that it was a kind of bug in Laravel, and Laravel has fixed it in minor versions (or hotfixes). I was using Laravel 5.7.9 and my vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php ->build() was like:

if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) {
    $packages = json_decode($this->files->get($path), true);
}

But in Laravel 5.7.29 PackageManifest.php , the same file is fixed:

if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) {
    $installed = json_decode($this->files->get($path), true);

    $packages = $installed['packages'] ?? $installed;
}

Same goes for Laravel 5.6.0 that had the bug, and is fixed in 5.6.40 Laravel 5.6.40 PackageManifest.php. I don't know from which minor version it has been fixed at each level, but I suggest to go for the last, like 5.7.29, 5.6.40 etc. Or you can go look the versions to see if it has been fixed.

NOW COMPOSER 2.0 IS VERY VERY FAST.

KeitelDOG
  • 4,750
  • 4
  • 18
  • 33
1

here's a solution that worked for me. https://github.com/composer/composer/issues/9340#issuecomment-716210369 change your laravel framework to 6.18.7 so that its compatible with composer 2

musangi
  • 31
  • 4
1

If you have composer version 2 upgrade your laravel to 6.2.

https://github.com/composer/composer/issues/9340#issuecomment-716210369

Webkix
  • 281
  • 3
  • 9
0

I had the same problem after i clone an laravel project and start composer install. Then I read through some solutions here. In my opinion, it is not a good idea to edit the laravel core. But if it's just for testing, why not.

My solution in my case was composer update instead composer install. In the case of composer update, it does not use the composer.lock file and updates the packages from composer.json. For me and in my special case works.

Maik Lowrey
  • 15,957
  • 6
  • 40
  • 79
0

On my computer composer version 2.0.9 was installed, I had the same problem when upgrade laravel project.

the solution is :

  1. Delete Vendor folder inside your project if exist.
  2. inside composer.json for laravel version write this "laravel/framework": "^6.0" don't forget ^ in front of 6.0 it needs to install latest version of laravel 6
  3. then composer update

finally, it works perfectly.

Lan Danel
  • 55
  • 7
  • Please don't forget to visit the Laravel docs upgrade guide, if you are increasing the framework version. https://laravel.com/docs/6.x/upgrade – nbsp Mar 04 '21 at 23:35
0

If the error is after self updating the composer, just replace composer with composer1.
Just change:

composer install ...

into:

composer1 install ...

Just this!

Mohsen Abasi
  • 2,050
  • 28
  • 30
0

I got this issue because of a Laravel and composer version are not compatible.

Following are the steps I follow to solve this issue:

  1. I update Laravel version from 6.1 to 6.20 in composer.json file Eg: "laravel/framework": "6.20.*"
  2. then delete composer.lock file.
  3. And run composer install command

Now Problem is fixed. :)

0

enter image description here

I've identified the root cause of this issue. The problem is that you've updated your machine's PHP version to a higher version, while your Laravel version is still below 6.20.

To fix this, please update your Laravel version by following these steps:

Update the 'laravel/framework' package to the latest version in the 6.x series. Run 'composer update' to update your project's dependencies. Finally, run 'composer install' to ensure all dependencies are properly installed.

  • 1
    Please read [Why should I not upload images of code/data/errors?](https://meta.stackoverflow.com/questions/285551/why-should-i-ot-upload-images-of-code-data-errors) to see how you can improve your answer. – Andy Preston Mar 06 '23 at 11:14
-1

run a composer upgrade. This work for me on laravel 7