Search code examples
phpcomposer-php

Composer: Command Not Found


From within the directory holding my composer.phar file, I can't execute any composer commands.

I can see Composer is running when I execute

php composer.phar 

But any direct composer statements fail.

Not sure if it matters but Composer was included within a cloned repository.

I just want to install a single Oauth library, then likely not touch Composer again for several months, so I don't need to run it globally. I'm just confused why I can't run Composer from within this directory.


Solution

  • Your composer.phar command lacks the flag for executable, or it is not inside the path.

    The first problem can be fixed with chmod +x composer.phar, the second by calling it as ./composer.phar -v.

    You have to prefix executables that are not in the path with an explicit reference to the current path in Unix, in order to avoid going into a directory that has an executable file with an innocent name that looks like a regular command, but is not. Just think of a cat in the current directory that does not list files, but deletes them.

    The alternative, and better, fix for the second problem would be to put the composer.phar file into a location that is mentioned in the path