What is the current behavior?
When fetching packages with yarn inside Docker, the command fails caused by a Git error.
I don't think the problem is related to any specific package, but rather the yarn command or something else.
Should I install Git separately before using yarn? That seems to solve to problem, but I would think that's handled by yarn itself. Git is not installed within the base Docker image (node-alpine).
error Couldn't find the binary git
Full log when running with verbose flag
Steps to reproduce the behavior:
What is the expected behavior?
Successfully install the packages without installing git beforehand inside the Docker image.
System:
Yes, git needs to be installed and available wherever yarn is run. Yarn will run git commands as child processes so it needs to be on the PATH.
I'm not sure why that isn't listed on the "getting started" or "installing" docs page 馃 I'll open an issue over on the docs repo to add this as a requirement.
@rally25rs Can you please explain what exactly is yarn running under the hood using Git?
Is it used to pull packages from Git repositories when specified like the example below, because don't see any dependency using that?
"my-package": "git+https://.."
The strange part is that it was working previously without any changes in the environment (Docker image, yarn & node versions, etc).
Just tested building the same image without this package and it worked fine:
"webpack-s3-plugin": "^1.0.3",
So it's maybe related to this package or any of his dependencies instead of a problem with yarn itself.
Ah, yeah, I was assuming you had some git dependencies. I think the yarn publish command might use it too. If you are just doing a normal install without any git dependencies and running into this, then can you share your package.json? I could try to reproduce it here and see at what point it tries to call git.
(going to reopen this issue until we can confirm why git is being called)
Sorry for the delayed response. As I said in the previous comment, I found that we have a dependency pulled from git:
webpack-s3-plugin - jsdelivr-cdn-data
That confirms that if we need to pull packages from git, we will need to have it installed in our environment. Are you still adding this to the docs so new users don't have similar problems?
I opened https://github.com/yarnpkg/website/issues/901 to capture the doc change.
I had the same issue. In my case I removed yarn.lock then I tested again and it worked!. You may have a try deleting yarn.lock. Maybe yarn requires git in certain dependencies declared in yarn.lock
I had the same issue. In my case I removed flow-typed install from the postinstall script because my project is using Flow typings, and the flow-typed library uses git to pull down the latest definitions.
Since it's required only during docker building, I was able to skip it changing the command to yarn install --ignore-scripts and the issue was resolved.
Same for me no resolution yet.
Should i be installing git in docker?
For me its working locally, but not in TeamCity (CI)
yarn install v1.22.0
info No lockfile found.
[1/4] Resolving packages...
error Couldn't find the binary git
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
ERROR: Service 'client' failed to build: The command '/bin/sh -c yarn install --frozen-lockfile --no-cache --production && rm -f .npmrc' returned a non-zero code: 1
@blowsie if you have a dependency that is a git url, then yarn uses the git command line tool to download it. The resolution is to have git available where yarn is being run.
@blowsie, I solved it with RUN apk add git before installing the dependencies
thanks @marciovsena that solves the problem for me.