website icon indicating copy to clipboard operation
website copied to clipboard

Docs for `yarn add` should document the URL/git repo formats accepted

Open markstos opened this issue 9 years ago • 4 comments

This concerns the docs for adding dependencies:

https://yarnpkg.com/en/docs/cli/add#toc-adding-dependencies

The docs say:

yarn add installs a package from a remote git repository

But should be clarified to document all the different URL formats accepted. For example, there are 'github:' and `git+https://' and other URL formats are useful document as acceptable formats.

Here's the npm install docs which references the git URL formats in supports there: https://docs.npmjs.com/cli/install

The Git Remote URL formats supports should also be documented on our package.json page:

https://yarnpkg.com/en/docs/package-json#toc-dependencies

NPM also provides the details of the Git Remote URLs in its package.json documentation as well:

https://docs.npmjs.com/files/package.json#dependencies

In addition to Git URLs, "file:" URLs are also accepted as dependencies, but not documented.

markstos avatar Nov 15 '16 16:11 markstos

With yarn 1.12.1 (and 1.10.x) I had to change from short form "gitlab:username/reponame" to long form with git+ssh and possibly also with .git in the end (mentioned as possible bug with #tags handling) - this is what worked for me: https://stackoverflow.com/a/53262092/296639

PS. The error messages I got when using the short form with a private repo said nothing, but that touches some other parts of the yarn code I suppose.

sesam avatar Nov 12 '18 12:11 sesam

IIRC the format is the same as whatever the git clone command would accept.

npm does a bunch of "we'll try to fix that for you" stuff to make URLs conform to what git will accept. yarn pretty much just passes it down to git.

rally25rs avatar Jan 07 '19 13:01 rally25rs

I don't concur :). My experience is along what others have reported, that some formats work, others not, or only if the repo is public. I work around this by maintaining a shell script in parallell with package.json, and now when colleges ask update? I say . update and that does yarn add (long line of private git repos)

But just yarn would've been nicer. I can dig up the formats that work and didn't work if PRs are welcome in documenting this

sesam avatar Jan 07 '19 14:01 sesam

if PRs are welcome in documenting this

PRs are very welcome 😺

rally25rs avatar Jan 07 '19 14:01 rally25rs