[InvalidArgumentException] Composer could not find a composer.json file

I was trying to create a new Laravel project when I get this error:

$ composer create-project --prefer-dist laravel/laravel stock
Installing laravel/laravel (v5.8.17)
- Installing laravel/laravel (v5.8.17): Loading from cache
Failed to execute unzip -qq 'stock//cb0489a0f2768cb9ee5b8942922e8a94' -d '/home/vagrant/Code/web/stock/vendor/composer/65f8a1d7'

[stock//cb0489a0f2768cb9ee5b8942922e8a94]
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
note: stock//cb0489a0f2768cb9ee5b8942922e8a94 may be a plain executable, not an archive
unzip: cannot find zipfile directory in one of stock//cb0489a0f2768cb9ee5b8942922e8a94 or
stock//cb0489a0f2768cb9ee5b8942922e8a94.zip, and cannot find stock//cb0489a0f2768cb9ee5b8942922e8a94.ZIP, period.

The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)
Unzip with unzip command failed, falling back to ZipArchive class
Created project in stock

[InvalidArgumentException]
Composer could not find a composer.json file in /home/vagrant/Code/web/stock/stock
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]

The solution is simple: delete the composer cache.

$ rm ~/.composer/cache/* -rf

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.