Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Couldn't find the binary git #2083

Closed
jdmunro opened this issue Nov 30, 2016 · 50 comments
Closed

Error: Couldn't find the binary git #2083

jdmunro opened this issue Nov 30, 2016 · 50 comments
Labels

Comments

@jdmunro
Copy link

jdmunro commented Nov 30, 2016

I am using:

  • yarn v0.17.9
  • macOS Sierra 10.12.1
  • Node v6.9.1

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

Trying to install packages using yarn. Outputs a strange error message:

[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error Couldn't find the binary git

If the current behavior is a bug, please provide the steps to reproduce.

yarn --pure-lockfile

Outputs the above error message.

Git is installed:

Admins-Mac-mini:BWA-BETA203-FAST admin$ whereis git
/usr/bin/git

What is the expected behavior?

Yarn should install the packages without emitting an error about git. If I run this command using an older version of yarn, v0.16.1, everything is fine.

@sebmck
Copy link
Contributor

sebmck commented Dec 1, 2016

What's the result of which git?

@jdmunro
Copy link
Author

jdmunro commented Dec 1, 2016

Admins-Mac-mini:~ admin$ which git
/usr/local/bin/git

That's a different path to whereis git.

@emolchanov
Copy link

+1 - same problem macOS 10.12.1

yarn --version
0.17.10

node -v
v6.9.1

which git                           
/usr/local/bin/git

whereis git
/usr/bin/git

and on windows 7 and 10 with git-scm

@Congelli501
Copy link
Contributor

I have the same problem under ubuntu 16.04, dans yarn 18.1.

The reported error is bad:
The node spawn call return a "ENOENT" error (https://github.com/yarnpkg/yarn/blob/master/src/util/child.js#L41)
This is not caused by the git binary not found, but by the cwd given in opts witch is not found.

This is because of the supportsArchive boolean:

  • either archive is not supported, and everything is cloned locally.
  • or archive is used and nothing is cloned

However, supportArchive can change while nothing was cloned (https://github.com/yarnpkg/yarn/blob/master/src/util/git.js#L338).

@vitch
Copy link

vitch commented Jan 13, 2017

Same thing happened to me after a yarn cache clean (trying to get a git branch dependency to update).

Removing the node_modules folder and running yarn again seemed to work around the issue.

@flocsy
Copy link

flocsy commented Jan 15, 2017

this happens here too after yarn cache clean both on linux and Mac

@emmanuel-isaac
Copy link

emmanuel-isaac commented Jan 17, 2017

I am experiencing this issue too. I started seeing it after running yarn cache clean && yarn clean.

I use a Mac

@flocsy
Copy link

flocsy commented Jan 18, 2017

Unfortunately even deleting node_modules/ doesn't fix the problem

@sirbarrence
Copy link

sirbarrence commented Jan 18, 2017

This seems to happen to me when using a "git+ssh" dependency where the commit hash is not at the HEAD of the branch. For example, my lockfile contains something like:

"foo-bar-baz@git+ssh://git@my-internal-git-host.dev:7999/asdf/foo-bar-baz.git":
  version "2.2.2"
  resolved "git@my-internal-git-host.dev:7999/asdf/foo-bar-baz.git#a5e6897042a496d70dbc57b1de8f8df5e8c0369c"
  dependencies:
...

At first, a5e6897042a496d70dbc57b1de8f8df5e8c0369c was the HEAD of the repo and yarn install worked fine. But when I committed some new revs to foo-bar-baz.git without updating the lockfile of the package making use of foo-bar-baz (because I didn't need to yet), then yarn install started failing with the 'Couldn't find the binary git' message.

a5e6897042a496d70dbc57b1de8f8df5e8c0369c still exists in the repo and npm can install it just fine.

If I manually change the commit hash in the lockfile to whatever the HEAD commit hash is in foo-bar-baz.git, yarn install starts working again.

Starting with an empty cache definitely triggers this behavior. Starting with previously cached packages may or may not trigger it. Not sure why.

Happens with yarn 0.18.1 and 0.19.1. Node 6.9.1

@Nighthawk22
Copy link

Had the same problem as @sirbarrence . After removing the lockfile it worked again

@vitch
Copy link

vitch commented Jan 20, 2017

Thanks @sirbarrence - that was spot on. If the commit referred to in yarn.lock isn't the head of the referenced branch then we get the error. The workaround is to manually edit the yarn.lock file and delete the section for the dependency in question. Running yarn again after this works and picks up the new commit.

@sirbarrence
Copy link

Thanks @vitch that can work for local development. For automated builds where manual intervention is undesirable or builds where you can't use the HEAD of the dependency yet for compatibility reasons, I'm having to consider reverting to npm until this is resolved.

@jcurtis
Copy link

jcurtis commented Feb 2, 2017

Seeing this as well - exactly the same setup as @sirbarrence

Looks like it might be fixed in 0.20 - https://github.com/yarnpkg/yarn/releases/tag/v0.20.0

image

@shprink
Copy link

shprink commented Feb 15, 2017

I confirm that 0.20 fixes it

@wufeng87
Copy link

wufeng87 commented Feb 20, 2017

Happens with Windows8 yarn 0.20.3 Node 6.9.5.

E:\codes\js\react\relax-master>yarn --version
0.20.3

E:\codes\js\react\relax-master>node -v
v6.9.5

E:\codes\js\react\relax-master>yarn install
yarn install v0.20.3
[1/4] Resolving packages...
[2/4] Fetching packages...
error Couldn't find the binary git
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

@rjnienaber
Copy link

I was having this same issue on yarn 0.21.3. Switching from the abbreviated SHA commit hash to the full SHA commit hash solved the problem for me.

@alansouzati
Copy link

I cannot experience this problem locally, but my CI (Drone CI) keeps hitting this problem. We have the same yarn version.

@ricardogama
Copy link

@alansouzati I believe you need to install git previously, for example:

pipeline:
  test:
    image: node:7-alpine
    commands:
      - apk add --no-cache git
      - yarn

@alansouzati
Copy link

thanks @ricardogama, my CI is passing now.

@Congelli501
Copy link
Contributor

I think this issue should be marked as resolved now.
The fix has been merged and is in the stable releases for a long time.

@nottrobin
Copy link

I'm seeing this issue on Ubuntu 16.04, because nodejs is still at version 4... If I upgrade to 6.. it seems to fix it.

@BYK BYK closed this as completed Oct 27, 2017
@BYK
Copy link
Member

BYK commented Oct 27, 2017

Closed since this seems to be resolved in recent versions.

@jdmunro
Copy link
Author

jdmunro commented Oct 27, 2017

Yep - definitely resolved for me.

@em9790
Copy link

em9790 commented May 31, 2019

Delete yarn.lock file
Try to run yarn install

@ghanbari
Copy link

@ricardogama thanks, i have same problem in node:11.5-alpine, after install git by apk it solved

@jake-wickstrom
Copy link

This issue is still occurring for me when run on my Jenkins server (although fine locally).

Node: 12.6.0
Yarn: 1.16.0

I can find the full repository that I am trying to install in the Yarn/Cache folder, so the failure must be occuring after yarn performs the git clone (so yarn also clearly has access to the git binary at some point to be able to clone)

I tried the various git+ssh://... suggestions above with no success. Any other ideas?

@inqueez
Copy link

inqueez commented Aug 27, 2019

Hey! I found that problem occurs in case when you add a dependency, this way

    "@assets/sprintf": "https://github.com/alexei/sprintf.js#^1.1.1",

after I changed this line to

    "@assets/sprintf": "alexei/sprintf.js#^1.1.1",

the problem is gone

@umairraza101
Copy link

For reference: when I had this error message, adding ssh:// resolved it for me. npm is able to deal with git+git@github.com:etc, but yarn required git+ssh://git@github.com:etc. The error message was not helpful to understand what was wrong, I had to see here that basically any error while fetching a git dependency causes this message to even consider that my dependency spec may need to be changed.

yarn -v shows 1.10.1

Thanks, this is working for me now

@maycom10110
Copy link

I solved this error by installing git on my computer

@milosdavidovic
Copy link

Sometimes it could be just that path to git is not added to the PATH environmental variable.
For Windows add these two (adjust if git is installed on different location):
C:\Program Files\Git\bin
C:\Program Files\Git\cmd\

@swushi
Copy link

swushi commented Mar 30, 2020

Install git at https://git-scm.com/
Run yarn cache clean and delete node_modules folder
Restart your terminal (To make sure that it recognizes that git is now installed)

@colemars
Copy link

colemars commented Apr 20, 2020

Hey! I found that problem occurs in case when you add a dependency, this way

    "@assets/sprintf": "https://github.com/alexei/sprintf.js#^1.1.1",

after I changed this line to

    "@assets/sprintf": "alexei/sprintf.js#^1.1.1",

the problem is gone

This caused my build to just hang forever

@syedarifandrabi
Copy link

simply install git on your system

@ArchanaShahRS
Copy link

  1. Use the following link to download Git
    https://git-scm.com/download
  2. Install it in your machine.
  3. Restart your machine.
  4. Try running same command again and it will no more throw error.
    Thanks @swushi It worked.

@Moggieggwp
Copy link

Have you correctly set your PATH to point at your Git installation?

You need to add the following paths to PATH:

C:\Program Files\Git\bin
C:\Program Files\Git\cmd
And check that these paths are correct – you may have Git installed on a different drive, or under Program Files (x86). Correct the paths if necessary.

@lynshashank
Copy link

lynshashank commented Sep 1, 2020

@alansouzati I believe you need to install git previously, for example:

pipeline:
  test:
    image: node:7-alpine
    commands:
      - apk add --no-cache git
      - yarn

Can u please elaborate how you had done this ??

@Birdy94
Copy link

Birdy94 commented Sep 30, 2020

Have you correctly set your PATH to point at your Git installation?

You need to add the following paths to PATH:

C:\Program Files\Git\bin
C:\Program Files\Git\cmd
And check that these paths are correct – you may have Git installed on a different drive, or under Program Files (x86). Correct the paths if necessary.

Had to restart windows my PC then it worked after doing this (y)

sylvainbx added a commit to sleede/fab-manager that referenced this issue Oct 6, 2020
this will try to fix the yarn error Couldn't find the binary git

see yarnpkg/yarn#2083
@lapwat
Copy link

lapwat commented May 22, 2021

@alansouzati I believe you need to install git previously, for example:

pipeline:
  test:
    image: node:7-alpine
    commands:
      - apk add --no-cache git
      - yarn

Can u please elaborate how you had done this ??

If you get this error when executing yarn in a Dockerfile, install git in your image.

RUN apk add --no-cache git

@sdaminul
Copy link

sdaminul commented Feb 1, 2022

### Install Git In your Computer. https://git-scm.com/

@adisonmasih
Copy link

Had the same problem as @sirbarrence . After removing the lockfile it worked again

Yes, Delete The yarn.lock file and it will start working again! thanks!

@LAART66
Copy link

LAART66 commented Jun 25, 2022

Hello I have same problem with lunching an yarn. When I lunch commend yarn it write me this (look bold text):

yarn install v1.22.19
warning package.json: No license field
warning @hashlips-lab/nft-erc721-collection-smart-contract@1.0.0: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
error Couldn't find the binary git
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Can somebody help me, please??

@lapwat
Copy link

lapwat commented Jun 28, 2022

@LAART66 you need to install Git on your computer

@ackvf
Copy link

ackvf commented Nov 21, 2022

I wonder why this is still necessary on my end when trying to install & build an app inside a docker?

RUN apk add --no-cache git

@lapwat
Copy link

lapwat commented Nov 23, 2022

I wonder why this is still necessary on my end when trying to install & build an app inside a docker?

RUN apk add --no-cache git

Because git is not shipped by default in the image you are using, and it is needed to download the dependencies of your app with yarn install.

I think that you can build without git if you have no external dependencies or if you copy the whole source code (app + deps) inside the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests