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

Can't install project when yarn cache is present and no global git user is configured #5303

Open
keradus opened this issue Feb 1, 2018 · 9 comments · May be fixed by #8595
Open

Can't install project when yarn cache is present and no global git user is configured #5303

keradus opened this issue Feb 1, 2018 · 9 comments · May be fixed by #8595

Comments

@keradus
Copy link

keradus commented Feb 1, 2018

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

What is the current behavior?
crash during instlalation

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

ker@dus:~/my-project λ yarn install
yarn install v1.3.2
info No lockfile found.
[1/5] Validating package.json...
[2/5] Resolving packages...
error Command failed.
Exit code: 128
Command: git
Arguments: pull
Directory: /home/keradus/.cache/yarn/v1/.tmp/5fe5dc997bcb53d9983a4dae633fdd3f
Output:
From git://github.com/adobe-fonts/source-sans-pro
   77ad88165..d975556bf  master     -> origin/master
 * [new branch]          PaulFix    -> origin/PaulFix
 * [new branch]          bulg-cyr   -> origin/bulg-cyr

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'keradus@XXX.(none)')
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

What is the expected behavior?
not crashing, eg using dummy git user

Please mention your node.js, yarn and operating system version.
node 8.9.4, ubuntu

@ghost ghost assigned rally25rs Feb 1, 2018
@ghost ghost added the triaged label Feb 1, 2018
@rally25rs
Copy link
Contributor

Yarn runs git commands in the background, so it looks like git pull is returning a non-zero exit code, which bubbles back up through yarn. It's not really explicitly stated anywhere in the Yarn docs that I know of, but your git system needs to be set up correctly (i.e. if running a git command on the command line doesn't work, then neither will Yarn).

Some other applications have this same issue https://stackoverflow.com/questions/11656761/git-please-tell-me-who-you-are-error which I think git requires because the pull command could perform an automerge in which case it would want to make a commit, which would need your user info.

Is there a reason you can't configure git with the name and email? Perhaps there is a way for Yarn to do the same thing without the git pull command which could circumvent this problem.

@keradus
Copy link
Author

keradus commented Feb 1, 2018

that's why I mentioned in issue summary:

no global git user is configured

that's exactly the reason of the issue.

but I find yarn using my git profile as abuse of my profile, yarn shall not do anything with my profile.
I do not configure global git profile, as I do have multiple git users (even for same git server), thus I want to be explicit with which user I'm commiting, so I have configure the user per-repo.
Creating my own dummy git-user is not an option, as it leads to situation when I will, accidentally, commit changes with that dummy user to real repo one day.

@keradus
Copy link
Author

keradus commented Feb 1, 2018

Also, be aware that if I rm -rf ~/.cache/yarn, everything is installed, even if it is still using git without global user under the hood

@rally25rs
Copy link
Contributor

That makes sense. Thanks for the additional info. Do you have a dependency that is a github url? I'm trying to trace back why it would be using git pull in the cache in the first place (I suspect the first install does a git clone which doesn't require a profile).

Setting a "dummy user" for the project seems questionable. We would have to start detecting if a user exists first, then set one, then clear it again when done. I think it might be easier to use git fetch && git reset --hard together instead of git pull which then shouldn't throw that git error.

@keradus
Copy link
Author

keradus commented Feb 1, 2018

yes, I do have git-based package, as it's visible in my first post:

git://github.com/adobe-fonts/source-sans-pro

in concrete, it's

"source-sans-pro": "git://github.com/adobe-fonts/source-sans-pro.git#2.020R-ro/1.075R-it",

worst case scenario, it could always clone the repo with given version:

git clone -b $branch_or_tag [email protected]:org-name/repo-name.git

@sth
Copy link
Contributor

sth commented Apr 17, 2018

Git should only need a user name/... when you want to commit. The "read only" operations usually don't need git info configured. But git pull might automatically do a merge, which would need a user name/..., but I don't think yarn would ever want to trigger a merge when updating its cache. Yarn shouldn't be creating new commits in the repositories it tries to clone.

So fetch + reset seems like the way to go. And if we don't need the checked out files, using a bare repository would further simplify the situation and save disk space an IO activity.

But it turns out yarn already did once use bare repositories and fetch instead of pull, it was changed in #514. It's not clear to me why/how exactly that change solved the bug it apparently did solve.

@keradus
Copy link
Author

keradus commented Apr 20, 2018

"good" there are some tests for that bug...

@mvdan
Copy link

mvdan commented Jul 26, 2018

We have hit this twice over the last few months on our CI builds. Is there any progress or suggested workarounds? The current workaround of manually clearing the cache isn't very practical.

@nightpool
Copy link

also ran into this issue today.

andersk added a commit to andersk/yarn that referenced this issue Mar 9, 2021
Also, use git remote set-head in case the repository’s default branch
has been renamed.

Fixes yarnpkg#5303.

Signed-off-by: Anders Kaseorg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants