pub icon indicating copy to clipboard operation
pub copied to clipboard

dependency version ranges don't work for github dependencies

Open DartBot opened this issue 9 years ago • 14 comments

Originally opened as dart-lang/sdk#22481

This issue was originally filed by [email protected]


What steps will reproduce the problem?

pubspec.yaml that lists a git dependency with a version range like this fails:

name: wService version: 1.0.3 dependencies:   wTransport:     git: [email protected]:Workiva/wTransport.git     version: "^1.0.0"

with this error:

Working dir: /Volumes/CASE/code/wService/examples/dart /usr/local/Cellar/dart/1.8.5/libexec/bin/pub get Resolving dependencies... Package wTransport has no versions that match >=1.0.0 <2.0.0 derived from:

  • wService 1.0.3 depends on version ^1.0.0 Process finished with exit code 1

But if version is specified as ">=1.0.0", it works as expected and installs the 2.0.0 tagged release.

For some reason, Dart doesn't recognize that any of the 1.0.x tagged versions are available for install. Any idea why that would be? Is something beyond a git tag with release notes required for Dart to recognize the version?

What is the expected output? What do you see instead?

expect install of wTransport library at version 1.0.3

What version of the product are you using?

1.8.5

On what operating system?

OSX

What browser (if applicable)?

N/A

DartBot avatar Jun 05 '15 22:06 DartBot

This comment was originally written by [email protected]


Maybe pub is doing this:

  1. see that wService depends on wTransport version ^1.0.0 (shorthand for ">=1.0.0 <2.0.0")
  2. get the latest version of github.com:Workiva/wTransport.git
  3. see that the latest version in pubspec.yaml is 2.0.0
  4. fail because 2.0.0 does not satisfy ">=1.0.0 <2.0.0"

I don't see anything in the documentation that leads me to believe pub is looking at git tags

DartBot avatar Jun 05 '15 22:06 DartBot

This comment was originally written by [email protected]


You're probably right John, but if it's not actually a bug, then it should be a feature request. Supporting GitHub version ranges should be much simpler than standing up a custom pub server (for private repos) because there's already a GitHub API that provides all the info needed.

DartBot avatar Jun 05 '15 22:06 DartBot

<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


John is right about how this works today. It does seem like it would be cool to support version resolution here, though, using a standard tag format to traverse through possible versions, after trying master first.

In order to avoid backwards incompatibilities, we'd probably need to only do this if a version constraint was present...

DartBot avatar Jun 05 '15 22:06 DartBot

<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


Removed Type-Defect, Priority-Unassigned labels. Added Type-Enhancement, Priority-Low labels.

DartBot avatar Jun 05 '15 22:06 DartBot

This comment was originally written by [email protected]


This would be huge for us, completely removing the need for us to internally run a pub server.

DartBot avatar Jun 05 '15 22:06 DartBot

<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


This would be a great way for an external user to dip their toes into pub development :-).


Added PatchesWelcome label.

DartBot avatar Jun 05 '15 22:06 DartBot

This comment was originally written by [email protected]


We're willing to take a crack at it. Can you point us in the right direction (where's the code)?

This would be a nice result coming out of the Dart Summit next week :).

DartBot avatar Jun 05 '15 22:06 DartBot

<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


Pub in general is in sdk/lib/_internal/pub in the main Dart repo. Within that directory, the file you'll mostly be working with will be lib/src/source/git.dart, which contains the code for the Git source. Most of the work will be making it support more of the interfaces that are supported by lib/src/source/hosted.dart, such as Source.getVersions().

Once you have it implemented, you'll need to write tests. Check out the existing version-resolution tests in test/get/hosted and test/upgrade/hosted and modify them for the new git behavior in test/get/git and test/upgrade/git.

DartBot avatar Jun 05 '15 22:06 DartBot

This comment was originally written by [email protected]


For someone that has never contributed to Dart/Pub, is this the best place to start? https://code.google.com/p/dart/wiki/Contributing

DartBot avatar Jun 05 '15 22:06 DartBot

I have a patch working for this issue here: https://github.com/dart-lang/pub/compare/master...computmaxer:github-version-ranges

However, I need to add/update tests. The README says to use pub run test, but the project isn't using the test package so this doesn't work. I can get them to run with pub global run test_runner but it takes a very long time to even discover all of the tests. Is that the best way to run the tests currently?

@nex3

computmaxer avatar Aug 08 '15 22:08 computmaxer

However, I need to add/update tests. The README says to use pub run test, but the project isn't using the test package so this doesn't work.

I'm not sure what you mean by that. Pub definitely does use the test package.

nex3 avatar Aug 10 '15 19:08 nex3

Yes, it looks like this is what I want to support, eventually (TM). /sub

matanlurey avatar May 26 '17 22:05 matanlurey