Search code examples
githubhomebrewyarnpkg

Trying to Yarn add a private Github repo and get 'couldn't find the binary git' error


I have a really simple repo in GitHub (/Hooks/), currently containing just 1 file, a simple Hooks.ts typescript file. On my local machine, in my Workspace, I've created a project folder and I can yarn add normal repositories like yarn add fuse.js but I wanted to yarn add my private repo yarn add Hooks using this format yarn add git+ssh//git@github.com:OrganisationName/Hooks.git but I just get Error: couldn't find the binary git'. I have permissions to the Hooks repo because I can push/pull from it. I'm on OSX Mojave (10.14.16) and installed Yarn via brew. My yarn version (yarn -v) is 1.22.10. This is the latest brew will install after running brew upgrade yarn.


Solution

  • This error "couldn't find the binary git" is related with not having installed git where the installation is made, Are you running these. commands inside a container? you might as well be installing openssh, is necessary too.

    for example in an alpine container

    apk add --no-cache git openssh
    yarn install
    

    If, just in case, you don't want to access to the repo trough SSH, you can access trough https+deploy-token, heres a gitlab example:

    git+https://<token-name>:<token>@gitlab.com/Username/Repository#<branch|tag>