-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Don't run git ls-remote
in the project directory
#6081
Comments
Why would you use a git dependency to include something that isn't a git repo, or isn't a valid git repo? This doesn't seem like a yarn problem, more like an invalid use case. |
@rally25rs please re-read the description. The dependency is a perfectly valid git repo: the problem here is when the working directory is not a valid git repo. Yarn should not have any assumptions about the working directory being a valid git repo. |
@rally25rs this happens when the working directory is mounted as a docker volume: meta-repo/
.git/ # directory
docker-compose.yml
submodule-app/ #mounted as a volume
.git # just a file
Dockerfile
.dockerignore # ignores .git in the COPY/ADD directive; volumes don't ignore For example, let's say I'm developing an app running in docker and want to add a new dependency; if the entire submodule directory is mounted as a volume, the I can hack this by making sure the parent directory contains the parent repository's |
I have the same use case as @davidroeca and the same issue. |
I also have the exact same problem as @davidroeca. I found a work around. In your Dockerfile: # Initialize an empty git repo.
RUN git init /fakegit
# Tell git to use that repo instead of the .git file in the submodule.
ENV GIT_DIR=/fakegit/.git Ig you're using docker compose just add the env var to environment:
GIT_DIR: /fakegit/.git |
What is the current behavior?
Currently, when installing a dependency from a git repo, yarn will at some point run
git ls-remote <url>
to find the tags in that repo.Unfortunately, there is a bug/feature in git, where
git ls-remote
will fail if run in an invalid git repo, even though it will work fine without any git repo.If the current behavior is a bug, please provide the steps to reproduce.
Easiest way to do this is to create a file called
.git
with the contentsgitdir: ../../.git/modules/something
package.json
with a git dependencyyarn
What is the expected behavior?
Install should succeed, taking no notice of invalid git repo.
Yarn should run
git ls-remote
in a different directory: one known to be outside any valid/invalid git repo. Where doesn't really matter.The text was updated successfully, but these errors were encountered: