I have a pubspec.yaml file like this:
name: My App
dependencies:
unittest: { sdk: unittest }
json_object:
git:
url: git://github.com/chrisbu/dartwatch-JsonObject.git
(I'm just using JsonObject as an example here)
When I run pub install
I get this error:
Package 'unittest' is depended on from both sources 'sdk' and 'hosted'
What does this mean and how can I resolve it?
Pub, the Dart package manager, identifies packages by name as well as where they come from. If pub detects two packages with the same name, but come from two different sources, it will throw an error like "Package foo is dependend on from both sources 'sdk' and 'hosted'"
To resolve this, you need to ensure all of your dependencies refer to the same package with the same source.
The right solution is for every package to stop using the sdk
sources, as all of the SDK packages are now hosted in pub.dartlang.org.
You should change:
dependencies:
unittest: { sdk: test }
Into this:
dependencies:
unittest: any
The any
means "any version from pub.dartlang.org"
The following packages are now in pub, their new canonical home:
If you use any of the above packages, please use foo: any
instead of {sdk: foo}
in your pubspec.yaml file.
Now, of course you as a developer can update your own pubspec.yaml, but you may not be able to control your 3rd party dependencies. I recommend that you contact your package's author via email (which you can get from pub.dartlang.org) as ask them to update to using hosted packages like unittest.
See more at http://news.dartlang.org/2012/12/sdk-packages-now-available-on-pub.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With