33

When installing dependencies via "composer install", I'm getting error:

Installing doctrine/lexer (dev-master bc0e1f0) Cloning bc0e1f0cc285127a38c6c8ea88bc5dba2fd53e94 [RuntimeException] Failed to clone http://github.com/doctrine/lexer.git, git was not found, check that it is installed and in your PATH env. 'git' is not recognized as an internal or external command, operable program or batch file.

I'm not sure what to do... I don't need git. Thanks!

1

7 Answers 7

45

Using --prefer-dist worked:

composer install --prefer-dist

to force dist part, which @ivoba mentioned; it seems default switch which uses git is --prefer-source.

34

You should install git first

apt-get install git
2
  • 1
    What if I do have git installed and working, why would I get this error in that case? Dec 5, 2016 at 19:13
  • @TheUnknownDev it could mean you're running the composer in the container (docker) which does not have the git installed
    – jave.web
    Sep 20, 2022 at 9:36
7

I had the same issue. So I first used

composer install --prefer-dist

But it didn't work for me.

Then I used these commands and I solved my issue.

apt-get install zip
composer install --prefer-dist

This works for me. I think this will help someone.

2
  • 1
    apt-get install zip or apt-get install git ?
    – URL87
    Mar 24, 2020 at 12:27
  • 1
    Installing zip allows composer to unzip a dist zipball. If you have --prefer-dist but no unzip command available, it will fall back to source and therefore relying on git.
    – cmbuckley
    Oct 20, 2021 at 19:23
6

I had the same problem in windows and already installed git, so I fixed it just adding

C:\Program Files (x86)\Git\bin

to my path enviroment var.

3

On El Capitan on a fresh installation you first may also run into this problem although GIT is installed. After typing sudo git --help in the terminal you get a request to agree to the XCode licence terms. Walk through this procedure and then you are good to go. Weird stuff!

2
  • This 100% helped me in a situation, so it's a good check. I noticed the Xcode agreement warning and wasn't sure what the heck it was about!
    – Adrian
    Oct 22, 2016 at 12:13
  • Mac users must check for this, this solves my issue on macOS Monterey.
    – Park Lai
    Nov 28, 2022 at 17:11
0

You will need git, almost always with composer.

from the requirements;

To install packages from sources instead of simple zip archives, you will need git, svn or hg depending on how the package is version-controlled.

best you get git :)

update:
you could also try to override the package definition, so that they will try to get zip instead:
As fake example:

         {
            "type": "package",
            "package": {
                "name": "doctrine/lexer",
                "version": "3.1.7",
                "dist": {
                    "url": "http://www.doctrine.net/files/doctrine.zip",
                    "type": "zip"
                }
            }

https://github.com/composer/composer/blob/master/doc/04-schema.md#repositories-root-only

I did not test this, and i predict you end up in hell ;) when you will try to rewrite the f.e. doctrine composer.json.

2
  • "instead of simple zip archives" - I don't have anything against zips, why can't installer use that (part of requirements) :)
    – my2c
    Jul 22, 2013 at 16:42
  • Thanks to your suggestion (there isn't any file that mentions lexer) and link and playing, I found a switch --prefer-dist, I'll post that as an answer.
    – my2c
    Jul 22, 2013 at 17:59
0
composer config repositories.data-migration-tool git https://github.com/magento/data-migration-tool

Normally when you install git it's bin directory name is github So use github instead of git

Now Command is as below

composer config repositories.data-migration-tool github https://github.com/magento/data-migration-tool

After this run below command

composer require magento/data-migration-tool:2.3.0

1
  • THX, that was the answer for me... With one extra: even when you use github driver, composer uses the git driver, when you add no-api: true. So for I removed the "no-api" flag and it worked without git binary
    – Radon8472
    Aug 9, 2022 at 21:07

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.