Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer error Could not open input file: composer

I'm having a problem with Composer. I have Composer installed globally on my machine. I am trying to install intercom using composer. I tried the command:

php composer.phar require intercom/intercom-php

but that returned "Could not open input file: composer.phar"

After investigating and reading the issues others have had I then tried

php composer require intercom/intercom-php

but that returned "Could not open input file: composer"

As I stated, I have Composer installed globally on my machine. I can type in the command "composer update" and it works from any directory.

like image 867
Chad Avatar asked Nov 28 '25 06:11

Chad


1 Answers

If you got composer installed globally and composer update just works then get rid of php and instead of

php composer require intercom/intercom-php

just do

composer require intercom/intercom-php

The reason why former form does not work while the latter does is that you are invoking php executable and pass composer as its argument. It is then treated by php binary as script file path and as there's neither relative nor absolute path segments used, just file name, then file composer is expected to exist in current working directory which is no the case. In second invocation, your shell will look for composer binary in all known paths defined in $PATH env variable.

If you wonder where composer executable realy lives, you can use

which composer

Or on Windows

where composer 
like image 130
Marcin Orlowski Avatar answered Nov 30 '25 19:11

Marcin Orlowski