pubspec.lock: Invalid version constraint

Created on 3 Sep 2018  Â·  4Comments  Â·  Source: dart-lang/pub

As requested by the error message, I'm submitting an issue. It suddenly started occuring when trying to get packages.

  • Dart: 2.1.0-dev
  • Flutter 0.6.0 beta
  • Flutter doctor – no issues found
  • Android SDK – up to date, if Android Studio is to be believed

Log:

G:\AndroidProjects\omnibus>pub --trace --verbosity=warning get --no-precompile
Error on line 407, column 9 of pubspec.lock: Invalid version constraint: Expected version number after "<" in "<empty>", got "empty>"
.
  dart: "<empty>"
        ^^^^^^^^^
package:pub/src/lock_file.dart 189:7    LockFile._wrapFormatException
package:pub/src/lock_file.dart 175:12   LockFile._parseVersionConstraint
package:pub/src/lock_file.dart 116:13   LockFile._parse.<fn>
dart:collection                         MapView.forEach
package:pub/src/lock_file.dart 113:23   LockFile._parse
package:pub/src/lock_file.dart 78:21    new LockFile.load
package:pub/src/entrypoint.dart 92:23   Entrypoint.lockFile
package:pub/src/entrypoint.dart 211:19  Entrypoint.acquireDependencies
===== asynchronous gap ===========================
dart:async                              _AsyncAwaitCompleter.completeError
package:pub/src/entrypoint.dart         Entrypoint.acquireDependencies
---- Log transcript ----
FINE: Pub 2.0.0
IO  : Spawning "cmd /c ver" in G:\AndroidProjects\omnibus\.
IO  : Finished ver. Exit code 0.
    | stdout:
    | |
    | | Microsoft Windows [Version 10.0.17134.228]
    | Nothing output on stderr.
ERR : Error on line 407, column 9 of pubspec.lock: Invalid version constraint: Expected version number after "<" in "<empty>", got "e
mpty>".
    |   dart: "<empty>"
    |         ^^^^^^^^^
FINE: Exception type: SourceSpanFormatException
ERR : package:pub/src/lock_file.dart 189:7    LockFile._wrapFormatException
    | package:pub/src/lock_file.dart 175:12   LockFile._parseVersionConstraint
    | package:pub/src/lock_file.dart 116:13   LockFile._parse.<fn>
    | dart:collection                         MapView.forEach
    | package:pub/src/lock_file.dart 113:23   LockFile._parse
    | package:pub/src/lock_file.dart 78:21    new LockFile.load
    | package:pub/src/entrypoint.dart 92:23   Entrypoint.lockFile
    | package:pub/src/entrypoint.dart 211:19  Entrypoint.acquireDependencies
    | ===== asynchronous gap ===========================
    | dart:async                              _AsyncAwaitCompleter.completeError
    | package:pub/src/entrypoint.dart         Entrypoint.acquireDependencies
---- End log transcript ----

pubspec.yaml:

name: omnibus
description: Mobile Omnibus app

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2

  http: ^0.11.3+16
  flutter_html: "^0.5.4"

  dynamic_theme:
    git:
      url: git://github.com/Norbert515/dynamic_theme.git

dev_dependencies:
  flutter_test:
    sdk: flutter

  fonts:
    - family: Courgette
      fonts:
        - asset: fonts/Courgette-Regular.ttf

pubspec.lock 406-8

sdks:
  dart: "<empty>"
  flutter: ">=0.5.0 <0.8.0"

Most helpful comment

Fixed

What did the trick was renaming the pubspec.lock file to pubspec.lock.old and running flutter --no-color packages get.

In the end, two lines changed:

  • 79 – no idea what it does
  • 407 – looks like now a proper Dart version is given there

All 4 comments

Fixed

What did the trick was renaming the pubspec.lock file to pubspec.lock.old and running flutter --no-color packages get.

In the end, two lines changed:

  • 79 – no idea what it does
  • 407 – looks like now a proper Dart version is given there

Getting same issue in Flutter development in Android Studio on Mac OS.

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.2+
  english_words: ^3.1.0

I got error after executing command --no-color packages get:

Error on line 21, column 20 of pubspec.yaml: Invalid version constraint: Cannot include other constraints with "^" constraint in "^0.1.2+".
  cupertino_icons: ^0.1.2+
                   ^^^^^^^

pub get failed (65)

That error means you cannot use ^ and + for the same package. It's one or the other.

As Atulin said you cannot use ^ and also a comma ,
just do it like this:

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.2
  http: 0.11.3+17

this works for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

isoos picture isoos  Â·  5Comments

jimsimon picture jimsimon  Â·  5Comments

tusharojha picture tusharojha  Â·  5Comments

seenickcode picture seenickcode  Â·  4Comments

ziyotko picture ziyotko  Â·  4Comments