yarn (and npm) install fails to install with packages from git paths
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.
- Checkout master branch
git checkout master&& cd /path/to/master - Create a base worktree directory
mkdir -p ./backends - Check-out random branch to a worktree
git worktree add ./backend/branch random-branch - Build and run the Docker container
source ./backend/branch/docker/scripts/provision.shWhat is the expected behaviour? That the branch builds without any errors. checkout to the branch directly works as expected. Also, locating the worktree outside themaster branchdirectory 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
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.
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.
Facing the same issue here on a public repository.
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.
I managed to handle that by using a script "prepack": "yarn build", then the consumer install it automatically