azamouchi's avatar

Valet installation fails with file_get_contents(): read of 8192 bytes failed with errno=21 Is a directory

I'm trying to install valet as mentioned in https://laravel.com/docs/8.x/valet#installation

When i run the following command composer global require laravel/valet i get this error :

[ErrorException]
  file_get_contents(): read of 8192 bytes failed with errno=21 Is a directory

php version : 7.14.1

composer version : 1.10.13

environment : Mac OS 10.15.6

0 likes
10 replies
Tray2's avatar

It seems to expect a file but it found a directory instead.

Check your ~/.composer directory. You might need to delete your vendor directory.

azamouchi's avatar

i tired to rename it my ~/.composer/vendor to ~/.composer/vendor_old but when i run the command again i get the following message

[ErrorException]
  file_put_contents(~/.composer/vendor/bin): failed to open stream: No such file or directory

``
Tray2's avatar

After you rename it you should run composer install then the composer global require laravel/valet

azamouchi's avatar

i don't think we are going in the right direction here, i have no project setup yet, i'm trying to install valet globally , here is the output of composer installafter renaming vendor to vendor_old

MacBook-Pro-de-Ayoub:~ ayoub$ composer install
Composer could not find the config file: /Users/ayoub/.composer/vendor/bin
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

Also here is the full logs i get when i try to run composer global require laravel/valet -vvv (after canceling the changes is did to the vendor folder)

Changed current directory to /Users/ayoub/.composer
Reading /Users/ayoub/.composer/composer.json
Loading config file /Users/ayoub/.composer/composer.json
Checked CA file /usr/local/etc/[email protected]/cert.pem: valid
Executing command (/Users/ayoub/.composer): git branch --no-color --no-abbrev -v
Executing command (/Users/ayoub/.composer): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/Users/ayoub/.composer): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/Users/ayoub/.composer): hg branch
Executing command (/Users/ayoub/.composer): fossil branch list
Executing command (/Users/ayoub/.composer): fossil tag list
Executing command (/Users/ayoub/.composer): svn info --xml
Reading /Users/ayoub/.composer/vendor/composer/installed.json
Running 1.10.13 (2020-09-09 11:46:34) with PHP 7.4.11 on Darwin / 19.6.0
Reading /Users/ayoub/.composer/composer.json
Loading config file /Users/ayoub/.composer/composer.json
Executing command (/Users/ayoub/.composer): git branch --no-color --no-abbrev -v
Executing command (/Users/ayoub/.composer): git describe --exact-match --tags
Executing command (/Users/ayoub/.composer): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/Users/ayoub/.composer): hg branch
Executing command (/Users/ayoub/.composer): fossil branch list
Executing command (/Users/ayoub/.composer): fossil tag list
Executing command (/Users/ayoub/.composer): svn info --xml
Reading /Users/ayoub/.composer/vendor/composer/installed.json


  [ErrorException]
  file_get_contents(): read of 8192 bytes failed with errno=21 Is a directory


Exception trace:
 () at phar:///usr/local/bin/composer/src/Composer/Command/RequireCommand.php:116
 Composer\Util\ErrorHandler::handle() at n/a:n/a
 file_get_contents() at phar:///usr/local/bin/composer/src/Composer/Command/RequireCommand.php:116
 Composer\Command\RequireCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:281
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:113
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Command/GlobalCommand.php:101
 Composer\Command\GlobalCommand->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:281
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:113
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:61
 require() at /usr/local/bin/composer:24
Snapey's avatar

composer install will act locally I think.

try composer global install

azamouchi's avatar

it is already there

MacBook-Pro-de-Ayoub:~ ayoub$ which composer
/usr/local/bin/composer
azamouchi's avatar

Can you explain why should i run composer install ? as i said before i'm not inside a working laravel project yet , i'm configuring my dev environment .

azamouchi's avatar
azamouchi
OP
Best Answer
Level 1

issue solved

I had a COMPOSER variable set to update my PATH variable; to include vendor/bin available to zshrc.

export COMPOSER="/Users/ayoub/.composer/vendor/bin"
export PATH="$COMPOSER:$PHP:$PATH"

So after I renamed the variable to MYCOMPOSER; it no longer threw that error. So it seems maybe internally COMPOSER created a conflict.

Tray2's avatar

Because it will install everything you removed by renaming the vendor directory,

Please or to participate in this conversation.