Description
I recently went to restrict a dependency to a specific version:
dependencies:
taskbox:
git: [email protected]:~z64/taskbox
version: 0.2.0
and received:
$ shards -v install
Resolving dependencies
git ls-remote --get-url origin
Fetching [email protected]:~z64/taskbox
git fetch --all --quiet
git tag --list --column=never
Unable to satisfy the following requirements:
- `taskbox (0.2.0)` required by `shard.yml`
Failed to resolve dependencies
so I did some checking:
taskbox $ git tag --list --column=never
0.1.0
0.1.1
0.2.0
taskbox $ cat shard.yml
name: taskbox
version: 0.2.0
Seeing as it wasn't working even when everything shown to me says "0.2.0" so far, I checked the source:
$ rg 'VERSION_TAG' src/
src/resolvers/git.cr
209: .compact_map { |tag| Version.new($1) if tag =~ VERSION_TAG }
src/config.cr
13: VERSION_TAG = /^v(\d+[-.][-.a-zA-Z\d]+)$/
and it would appear there is a hard requirement that tags start with "v".
The docs have this to say about git
:
git
A Git repository URL (string).
The URL may be any protocol supported by Git, which includes SSH, GIT and HTTPS.
The Git repository will be cloned, the list of versions (and associated shard.yml) will be extracted from Git tags (e.g., v1.2.3).
One of the other attributes (version, tag, branch or commit) is required. When missing, Shards will install the HEAD refs.
Example: git: git://git.example.org/crystal-library.git
If I am not missing something, if the "e.g., v1.2.3" was supposed to convey this requirement, I think it would be nice to reword this section to make it more clear - or even better, an improved error message.
Personally, I'm not sure that this requirement is necessary in the first place, but I don't really mind as long as the above UX could be smoothed over.