Dart versioning - no matching version - dart

In my angular2 project I don't manage to add the "google_maps: 3.1.0" dependency.
It seems that this library is in conflict with "angular2: 2.0.0-beta.20".
The error message is :
Package code_transformers has no versions that match >=0.4.1 <0.5.0 derived from:
- build 0.3.0 depends on version ^0.4.1
However, "google_maps: 3.1.0" do not contain "code_transformers" or "build" package in its dependencies and transitive dependencies.
Thanks for your help.

This means that pub get or pub upgrade could not find a set of dependencies that are compatible.
Try to commenting out all dependencies except two and run pub get or pub upgrade again. Then add one dependency and run again and so on until you get the error. This way you can figure out what dependency causes the problem.
Don't use any as dependency constraint in your pubspec.yaml. This is known to cause troubles because pub has to analyze the whole search space which is gigantic.

Related

What we add under dev_dependencies in flutter

I have a silly question regarding dev_dependencies in flutter, I am planning to use mock_cloud_firestore and in its installation page it says that we need to add it in the dependencies section of pubspec.yaml
I think mock_cloud_firestore is not a production dependency but a dev dependency if so why we need to add it under dependencies?
Also what we add under dev_dependencies?
Thanks.
you can run below command flutter pub add <packagename> --dev to add under dev dependencies
and you can run below command flutter pub add <packagename> to add normal dependencies.
Both make an entry within the pubspec.yaml file under different headers.
dev_dependencies only have packages and tools which help the development process for the developer and are not really needed in production . eg. code generation etc
This issue is mentioned in Dart's official docs:
Pub supports two flavors of dependencies: regular dependencies and dev dependencies. Dev dependencies differ from regular dependencies in that dev dependencies of packages you depend on are ignored
Therefore, I believe it safer to put it under dependencies during development and remove it from pubspec when personal testing is finished. But below quote from the official doc is more clear:
The rule for deciding between a regular or dev dependency is simple: If the dependency is imported from something in your lib or bin directories, it needs to be a regular dependency. If it’s only imported from test, example, etc. it can and should be a dev dependency.

Dart's pub get command can't find latest versions of some dependencies

I've noticed on a few occasions that when I setup some dependencies in my pubspec.yaml pointing to the latest version, they aren't found when I run pub get.
For instance, the dependency source_gen. The latest version of source_gen is clearly 0.5.0+1. So I'll setup my pubspec.yaml file as follows:
dependencies:
source_gen: "^0.5.0+1"
Then I run pub get, and I get the following error:
Resolving dependencies...
Package source_gen has no versions that match >=0.5.0+1 <0.6.0 derived from:
- ServerErrors depends on version ^0.5.0+1
I tried several of the most recent versions, without much luck. Finally if I do the following:
dependencies:
source_gen: any
and then run pub get, source_gen version 0.4.7 is installed. I'm not sure I understand why. I'm using the dart sdk version 1.16.0. This is the second dependency I've had this issue with and I'm a little confused.
EDIT: As requested by Gunter, the full list of my dependencies:
dependencies:
http: "^0.11.3+7"
dartson: "^0.2.5"
intl: "^0.12.7+1"
mailer: "^1.0.0"
That's a known issue of pub. This means pub just wasn't able to resolve a compatible set of dependencies. Unfortunately the error message is misleading.
pub also prints the same error when one of the dependencies isn't compatible with the used Dart SDK version.

Pub warnings while trying to run bwu_datagrid 0.0.18 and polymer+angular

I'm trying to create a simple project with the latest versions of polymer, angular, and bwu_datagrid 0.0.18. I can't get pass the pub get, I get a warning and pub never downloads bwu_datagrid. I need help getting these 3 gems to work in symphony.
pubspec.yaml:
name: angu_poly
description: A sample web application
dependencies:
angular: any
polymer: any
bwu_datagrid: "0.0.18"
This is the warning I get:
Pub get failed, [1] Resolving dependencies...
Incompatible version constraints on barback:
- polymer 0.10.0-pre.0 depends on version >=0.9.0 <0.13.0
- pub itself depends on version >=0.13.0 <0.15.3
** Warning: Application may fail to run since packages did not get installed.Try running pub get again. **
Just in case, I'm on the latest dart editor/sdk:
Dart Editor version 1.7.2.release (STABLE)
Dart SDK version 1.7.2
Add a specific version constraint to you pubspec.yaml.
dependencies:
polymer: '>=0.15.1 <0.16.0'
This might lead to follow up errors. Continue accordingly for similar errors.
As last resort you can add dependency overrides to force a package no matter if it fulfills the constraints defined in the other imported packages (use at your own risk though).
dependency_overrides:
some_package: '=>1.0.0 <1.1.1'

Dart: pub get vs pub upgrade

According to the pub get docs the main difference between pub get and pub upgrade is:
If a lockfile already exists, pub get uses the versions of dependencies locked in it if possible. If a dependency isn’t locked, pub will get the latest version of that dependency that satisfies all the version constraints. This is the primary difference between pub get and pub upgrade, which always tries to get the latest versions of all dependencies.
But this leaves me with a few questions.
What do they mean by "If a dependency isn't locked...? Locked?!? Like in version control? File system lock? What is this lock of which they speak?
Still not clearly understanding the difference between these two commands. Are they saying that pub get takes version constraints into account, and that pub upgrade doesn't?
It is locked when the pubspec.lock file contains an entry for this dependency.
You can change the dependency in pubspec.lock manually to specify exactly what version you want to use.
pub upgrade checks for the newest version that fits your pubspec.yaml configuration and updates your pubspec.lock file automatically.
when pubspec.lock is checked in with your package code in a CVS repository you are able to later reproduce the exact same setup as you had when you checked in your code even when your pubspec.yaml allowed a wider range of versions for a dependency.
see also
Upgrading a dependency
In Dart and Pub, should I add pubspec.lock to my .gitignore?

pub install does not work in Dart

I am trying to install glmatrix using pub install. My OS is Windows 7 and I have Git installed.
Here is my pubspec.yaml
name: WebGLTut1
description: A sample application
dependencies:
glmatrix:
git: git://github.com/pjako/glmatrix.dart.git
When I run pub install I get the following error:
Running pub install ... Pub install fail, FormatException: Could not
parse "git://github.com/pjako/glmatrix.dart.git".".
I googled a while to find a solution but couldn't. Please help.
UPDATE#1:
I found the problem. There has to be a TAB/Space when specifying git: url in pubsec.yaml as follows.
glmatrix:
git: git://github.com/pjako/glmatrix.dart.git
This solved the previouse problem of FormatException. But now when I run pub install again it throws theis error.
Running pub install ... Pub install fail, Git failed.
As you identified you update, yaml files are whitespace sensitive; that's why you don't have to use lots of curly braces like json. :)
I see a few of possible problems here:
First
Glmatrix doesn't appear to have its own pubspec defined. Libraries participating in the package system much declare a pubspec file with the name property defined. The name is important because pub uses it when you declare your dependencies. Let's say you had a project called toast with the following simple pubspec:
name: butter
version: 0.0.0
Then you would need to declare your dependency to that project like so:
dependencies:
butter:
git: git://github.com/foo/toast.git
Have the project owner make the changes or fork it yourself, add the pubspec, and then reference your fork in your pubspec.
Second
Glmatrix is does not conform to the pubspec package layout conventions (your own projects should also conform to this). Although I believe that pub may handle non-conforming layouts currently, it may not in the future. So again, you can either ask the project owner to fix, or fork and fix it yourself.
Third
Since you are on windows, make sure git is in your system PATH variable. If you are using the bash shell, git will work, but it's not going to work outside of bash (like from Dart editor) until you add it to your PATH.

Resources