Yarn: `yarn add` not support git address with branch

Created on 14 Mar 2017  路  11Comments  路  Source: yarnpkg/yarn

Node Version: v7.6.0
yarn Version: 0.15.1

In my package.json:

 "<node-xxxx>": "github:<gitUserName>/<projectName>#<Branch-not-master>",

Got:

yarn add v0.15.1
[1/5] 馃攳  Resolving packages...
error Couldn't find match for "master" in "v1,v2" for "github:<gitUserName>/<projectName>".
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.

It doesn't had master branch.

Most helpful comment

For me yarn add git+ssh://[email protected]/<gitUserName>/<projectName>.git#<Branch> works when adding, but when running fresh yarn install the branch is ignored and it grabs master
Yarn v0.21.3

All 11 comments

We use 0.17.4 which has support for github package on whatever SHA (branch or commit).

I updated v0.21.3
Got an error error An unexpected error occurred: "Error connecting to repository. Please, check the url.".

EDIT:
I found why. yarn does not support private project!

Our github project dependency is also a private repository. The computer has an ssh key with access to the private repository.

npm work fine

How to debug this?

Cause HERE
Request "https://github.com/<private-project>.git/info/refs?service=git-upload-pack" finished with status code 401.

Any walkaround for this?

For me yarn add git+ssh://[email protected]/<gitUserName>/<projectName>.git#<Branch> works when adding, but when running fresh yarn install the branch is ignored and it grabs master
Yarn v0.21.3

The following script doesn't repro your issue - can you update it to highlight the problem you have (with the latest release), then create a new issue if it's still there? Thanks!

#!/usr/bin/env bash

YARN=${YARN:-yarn}

TEMP="$(mktemp -d)"
trap 'rm -rf "$TEMP"' EXIT

echo $TEMP
cd "$TEMP"

printf '{ "name": "main", "version": "1.0.0", "license": "MIT", "dependencies": {} }' > package.json

$YARN cache clean

$YARN add git+ssh://[email protected]/arcanis/private-pkg.git
$YARN install

$YARN add git+ssh://[email protected]/arcanis/private-pkg.git#branch
$YARN install

ls -l node_modules node_modules/*

I wasn't able to reproduce with your script either, I must have been confused somewhere. Thanks!

About my issue, I finally found out WHY.

I use github:<gitUserName>/<projectName>#<Branch-not-master> as my git remote url.
yarn use https protocol fetch data, but npm used git.

SO, I need provide procotol on the remote url!

@arcanis

This is less painful than publishing a namespaced package:

yarn add git+ssh://[email protected]/yargs/yargs.git
Was this page helpful?
0 / 5 - 0 ratings