yarn icon indicating copy to clipboard operation
yarn copied to clipboard

yarn (and npm) install fails to install with packages from git paths

Open ojengwa opened this issue 6 years ago • 5 comments

Probably a bug Fails with both tools...

What is the current behaviour? Running yarn install (npm install) as part of a container build process for a git worktree fails with the following log:

yarn install v1.5.1
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads https://******:********@host.com/****/package.git
Directory: /workdir/app
Output:
fatal: Not a git repository: /*********/master/.git/worktrees/branch-dir".
info If you think this is a bug, please open a bug report with the information provided in "/workdir/app/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

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

  1. Checkout master branch git checkout master&& cd /path/to/master
  2. Create a base worktree directory mkdir -p ./backends
  3. Check-out random branch to a worktree git worktree add ./backend/branch random-branch
  4. Build and run the Docker container source ./backend/branch/docker/scripts/provision.sh What is the expected behaviour? That the branch builds without any errors. checkout to the branch directly works as expected. Also, locating the worktree outside the master branch directory works too. Please mention your node.js, yarn and operating system version. Node version: v9.11.2 Yarn version: 1.5.1 Docker base image: Debian Jessie Host OS: MacOS 10.14.6

ojengwa avatar Sep 10 '19 05:09 ojengwa

Is this a private repo? Can you log into docker container and run git clone git://...

Saw this exact error a lot on CircleCI Was always a permissions issue. Didn't have access to private repo. Lot's of steps in circle ci for fixing this. For docker, you probably need ssh keys copied over

Also saw sudo screwing it up. Regular user on container had correct permissions but using sudo would fail. Sudo doesn't use the same ssh keys.

david-harkness avatar Oct 08 '19 14:10 david-harkness

I am also facing same issue. Yes its an private repo, but i have credentials in ~/.netrc file, npm install is also able to install these packages, but yarn install is not adding them.

vivekfyi avatar Apr 09 '20 09:04 vivekfyi

Facing the same issue here on a public repository.

gnutix avatar Mar 03 '22 17:03 gnutix

In a git worktree, the repo root has a .git text file which tells git where to find the real repo. git ls-remote hates this, and blows up with this "not a git repository" error.

The effect is that yarn has a bug: it cannot install project dependencies in a git worktree when one of those deps is referenced by a git URL.

I encountered this with yarn v1.22.15.

mildmojo avatar Apr 14 '22 20:04 mildmojo

I managed to handle that by using a script "prepack": "yarn build", then the consumer install it automatically

michenriqwotc avatar Jul 14 '25 16:07 michenriqwotc