14

Upgrading from Craft 3.4.20 running Composer 1.10.17 on PHP 7.2. Running ./craft update all returns the following error:

error: Unknown package has no name defined. [followed by JSON object related to GuzzleHTTP]

The error appears to be related to GuzzleHTTP. For testing I did the following:

  1. Deleted the /vendor directory.
  2. Deleted the composer.lock file.
  3. Removed all composer.json dependencies except craftcms/cms, vlucas/phpdotenv and ext-json.
  4. Ran composer install.
  5. Ran ./craft update all.

Yielded same error.

Unfortunately, I am unable to find any information about this error from Composer documentation or bug reports.

7 Answers 7

17

Very similar to Devin's answer.
I came up against this on Friday and I had to follow these steps to resolve this issue.

  1. Nuke the vendor folder within the project. rm -rf vendor/
  2. Nuke the composer.lock file within the project. rm composer.lock
  3. Clear the composer cache composer clearcache within the project.
  4. Rollback to composer v1 composer self-update --1
  5. Update composer globally to smooth it out composer global update
  6. Then reinstall composer install within the project.
  7. Finally, I was able to run ./craft update all

Hope this helps anyone else who comes up against this. It took several hours to resolve and figure out the necessary steps.

3
  • Thanks, @terry-upton, for taking the time to post your solution. thumbs up
    – Mario
    Commented Mar 31, 2021 at 9:59
  • also, deleting .config/composer/vendor is needed because composer global clearcache also fails
    – hbt
    Commented Dec 29, 2021 at 17:16
  • I had success by doing the same, the only difference was, running composer global update balked, I ended up doing composer update instead.
    – 4midori
    Commented Jan 2, 2023 at 21:38
11

The problem seems to be with parsing vendor/composer/installed.json Once I deleted it - install went well. Even without deleting other files. This one is generated one. You can also simply remove whole vendor/composer directory.

5

I managed to solve this by running:

  1. rm -rf vendor/
  2. rm composer.lock

At this point, the error still persisted when running composer update or composer dumpauto but then after running:

  1. composer global clearcache

everything worked as per normal.

My guess is something got corrupted within in composers' global cache. I am not sure if the first two steps are necessary but that's how I managed to fix it.

5
rm vendor/composer/installed.json 
composer install 

Maybe installed.json was generated with composer 2.x and you are trying run it now with composer 1.6 or 1.8.

Also maybe update composer it also fixes the problem

2

The JSON object being returned with the error appeared to be related to a JSON object containing all the globally installed packages.

After 2 hours of unsuccessful debugging, I completely reinstalled composer (same version) and the issue appears to have resolved itself. Unsure as to the exact cause, but possibly my global composer.json was corrupt.

3
  • 1
    Did you by any chance experiment with Composer 2? I got the same error after rebuilding a Docker container that had Composer 2 and the rebuild rolled it back to version 1 but some Composer directory was persisted in a volume and I guess I had mixed files from different versions. In my case upgrading composer to version 2 again resolved the issue.
    – Rafał G.
    Commented Nov 25, 2020 at 15:33
  • I did experiment with Composer 2 at some point prior to this issue. That may be the issue.
    – Jason
    Commented Dec 2, 2020 at 17:47
  • For me, I downgraded to composer 1 "composer self-update --1" then ran "composer global update" and was able to run update through the CLI and the app. Commented Dec 31, 2020 at 17:32
1

i was having this error i tried the things you say here like deleting the vendor, the lock and clear cache and didn't work.

I was using composer 2.0.9

But when i changed my composer to 1.8.4 solved my issue

1

Make sure you are running this as the correct user.

I ran in the same problem and was about to delete everything according to the solution by Terry when I noticed I hadn't the permission to delete the files.

Switched to the user I used to create the project and the composer commands worked (without having to delete anything).

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.