Bloc: [flutter_todos] flutter get packages fail.

Created on 18 Mar 2019  ยท  30Comments  ยท  Source: felangel/bloc

Describe the bug
Following the tutorial for flutter_todos I get the error:

[flutter_todos] flutter packages get
Running "flutter packages get" in flutter_todos...              
Error on line 11, column 11: Invalid description in the "todos_repository_simple" pubspec on the "todos_repository_core" dependency: "../todos_repository_core" is a relative path, but this isn't a local pubspec.

   โ•ท

11 โ”‚     path: ../todos_repository_core

   โ”‚           ^^^^^^^^^^^^^^^^^^^^^^^^

   โ•ต
pub get failed (65)
exit code 65

To Reproduce
Steps to reproduce the behavior:

  1. Create a new project flutter create flutter_todos
  2. Change the content of pubspec.yml to the following:
name: flutter_todos
description: A new Flutter project.

environment:
  sdk: ">=2.0.0 <3.0.0"

dependencies:
  meta: ">=1.1.0 <2.0.0"
  equatable: ^0.2.0
  flutter_bloc: ^0.7.0
  flutter:
    sdk: flutter

dependency_overrides:
  todos_app_core:
    git:
      url: git://github.com/brianegan/flutter_architecture_samples
      path: todos_app_core
  todos_repository_core:
    git:
      url: git://github.com/brianegan/flutter_architecture_samples
      path: todos_repository_core
  todos_repository_simple:
    git:
      url: git://github.com/brianegan/flutter_architecture_samples
      path: todos_repository_simple

flutter:
  uses-material-design: true
  1. run flutter packages get

Expected behavior
Get all packages with no errors

*Logs *
flutter analyze output:

PS C:\Repos\bloc\examples\flutter_todos> flutter analyze
Error on line 11, column 11: Invalid description in the "todos_repository_simple" pubspec on the "todos_repository_core" dependency: "../todos_repository_core" is a relative path, but this isn't a local pubspec.
   โ•ท
11 โ”‚     path: ../todos_repository_core
   โ”‚           ^^^^^^^^^^^^^^^^^^^^^^^^
   โ•ต
Running "flutter packages get" in flutter_todos...
pub get failed (65)

flutter doctor output:

PS C:\Repos\bloc\examples\flutter_todos> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[โˆš] Flutter (Channel master, v1.3.11-pre.40, on Microsoft Windows [Version 10.0.17763.379], locale en-CA)
[โˆš] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[โˆš] Android Studio (version 3.3)
[โˆš] VS Code
[โˆš] VS Code, 64-bit edition (version 1.32.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.
PS C:\Repos\bloc\examples\flutter_todos>
bug

Most helpful comment

@huynguyennovem exit code 0 means everything went well ๐Ÿ˜Š

oh, sorry about that and thank for your support!

All 30 comments

@nosmirck thanks for opening this issue!

Can you please try with the following pubspec.yaml and let me know if it works?

name: flutter_todos
description: A new Flutter project.

environment:
  sdk: ">=2.0.0 <3.0.0"

dependencies:
  meta: ">=1.1.0 <2.0.0"
  equatable: ^0.2.0
  flutter_bloc: ^0.7.0
  flutter:
    sdk: flutter

dependency_overrides:
  todos_app_core:
    git:
      url: https://github.com/brianegan/flutter_architecture_samples
      path: todos_app_core
  todos_repository_core:
    git:
      url: https://github.com/brianegan/flutter_architecture_samples
      path: todos_repository_core
  todos_repository_simple:
    git:
      url: https://github.com/brianegan/flutter_architecture_samples
      path: todos_repository_simple

flutter:
  uses-material-design: true

Thanks! ๐Ÿ‘

Thanks for the fast response @felangel
I'm getting the same issue with new pubspec content:

[flutter_todos] flutter packages get
Running "flutter packages get" in flutter_todos...              
Error on line 11, column 11: Invalid description in the "todos_repository_simple" pubspec on the "todos_repository_core" dependency: "../todos_repository_core" is a relative path, but this isn't a local pubspec.

   โ•ท

11 โ”‚     path: ../todos_repository_core


   โ”‚           ^^^^^^^^^^^^^^^^^^^^^^^^
   โ•ต
pub get failed (65)
exit code 65

I just tried cloning the whole bloc repo, navigated to examples/flutter_todos and tried flutter packages get and I got the same error.

@nosmirck oops that's my fault! Just pushed a fix for this. The following pubspec.yaml should work. Let me know if that helps.

name: flutter_todos
description: A new Flutter project.

environment:
  sdk: ">=2.0.0 <3.0.0"

dependencies:
  meta: ">=1.1.0 <2.0.0"
  equatable: ^0.2.0
  flutter_bloc: ^0.7.0
  flutter:
    sdk: flutter

dependency_overrides:
  todos_app_core:
    git:
      url: https://github.com/brianegan/flutter_architecture_samples
      path: todos_app_core
      ref: 0d047565ea5bf28c2b2cbdd7a7d9a9d14fff6945
  todos_repository_core:
    git:
      url: https://github.com/brianegan/flutter_architecture_samples
      path: todos_repository_core
      ref: 0d047565ea5bf28c2b2cbdd7a7d9a9d14fff6945
  todos_repository_simple:
    git:
      url: https://github.com/brianegan/flutter_architecture_samples
      path: todos_repository_simple
      ref: 0d047565ea5bf28c2b2cbdd7a7d9a9d14fff6945
flutter:
  uses-material-design: true

@felangel same error.

I believe the problem is here:

https://github.com/brianegan/flutter_architecture_samples/blob/master/todos_repository_simple/pubspec.yaml

The reference for todos_repository_core on line 11 is a relative path.

@nosmirck did you try the latest pubspec.yaml?

Yes I did.

PS C:\Repos\flutter_todos> flutter packages get
Error on line 11, column 11: Invalid description in the "todos_repository_simple" pubspec on the "todos_repository_core" dependency: "../todos_repository_core" is a relative path, but this isn't a local pubspec.
   โ•ท
11 โ”‚     path: ../todos_repository_core
   โ”‚           ^^^^^^^^^^^^^^^^^^^^^^^^
   โ•ต
Running "flutter packages get" in flutter_todos...
pub get failed (65)

@nosmirck did you delete your pubspec.lock?

I just created a clean project and tested it and it seems to work for me. ๐Ÿค”

Just did, same error.

Just to confirm:

  1. create a directory (mkdir tmp)
  2. create a pubspec.yaml in tmp (touch tmp/pubspec.yaml)
  3. Paste the contents into the pubspec.yaml
name: flutter_todos
description: A new Flutter project.

environment:
  sdk: ">=2.0.0 <3.0.0"

dependencies:
  meta: ">=1.1.0 <2.0.0"
  equatable: ^0.2.0
  flutter_bloc: ^0.7.0
  flutter:
    sdk: flutter

dependency_overrides:
  todos_app_core:
    git:
      url: https://github.com/brianegan/flutter_architecture_samples
      path: todos_app_core
      ref: 0d047565ea5bf28c2b2cbdd7a7d9a9d14fff6945
  todos_repository_core:
    git:
      url: https://github.com/brianegan/flutter_architecture_samples
      path: todos_repository_core
      ref: 0d047565ea5bf28c2b2cbdd7a7d9a9d14fff6945
  todos_repository_simple:
    git:
      url: https://github.com/brianegan/flutter_architecture_samples
      path: todos_repository_simple
      ref: 0d047565ea5bf28c2b2cbdd7a7d9a9d14fff6945
flutter:
  uses-material-design: true
  1. Save and run flutter packages get

You still get the error?

Maybe you have the core on your cache and that's why you don't have the error. Go to your flutter installation folder > .pub-cache/git and delete it's content, then try running flutter packages get

I still have the same error on both of my machines (Mac and Windows)

@nosmirck yeah you're probably right. I just checked and the commit I was referencing should have the same issue. I ended up just moving the repositories into the flutter_todos project since that was the most straightforward solution. Everything should work now if you just pull master ๐Ÿ‘

Great! flutter_todos from bloc repo works, but creating from scratch (like the tutorial) still presents the issue with the pubspec.

The problem is here: https://github.com/brianegan/flutter_architecture_samples/blob/master/todos_repository_simple/pubspec.yaml

Make the dependency relative to the git url, that should fix it.

@nosmirck I updated the tutorial to reference the local repositories as well. I'll try to talk to Brian Egan (the owner of the todos_repository) and see if he's okay with making the change to use a git import instead of a relative import but in the meantime at least people who clone and try to run the flutter_todos example won't have any problem.

Perfect! good solution.

I can close this now :) thanks for the help!

@nosmirck Thanks for your help; I really appreciate it!

Target of URI doesn't exist: 'package:flutter_todos/models/models.dart'.

this is what I got

@rahi0 you need to create a barrel file for the model exports.

https://github.com/felangel/bloc/blob/master/examples/flutter_todos/lib/models/models.dart

Iโ€™ll update the documentation ๐Ÿ‘

hi, still get this issue in 2020. How to resolve this?

@huynguyennovem can you describe the steps you're taking and the error you're getting? Thanks ๐Ÿ‘

@huynguyennovem can you describe the steps you're taking and the error you're getting? Thanks ๐Ÿ‘

I got the error message same as @nosmirck . After checking this, I see that there is missing todos_repository_simple in the repository

@huynguyennovem you have the same pubspec.yaml as https://github.com/felangel/bloc/blob/master/examples/flutter_todos/pubspec.yaml?

Yes, I have the same one.

Can you share a link to your repo so I can try to run it locally?

@huynguyennovem just tried and had no trouble ๐Ÿค”
Have you tried clearing your pub cache?

@huynguyennovem just tried and had no trouble ๐Ÿค”
Have you tried clearing your pub cache?

hmm, I tried flutter clean then get package again. And the result is:

E:\FlutterSDK\flutter\bin\flutter.bat --no-color pub get
Running "flutter pub get" in bloc_todoapp2...                   
! todos_app_core 0.0.0 from git https://github.com/felangel/flutter_architecture_samples at 71f32b in todos_app_core

! todos_repository_core 0.0.0 from git https://github.com/felangel/flutter_architecture_samples at 71f32b in todos_repository_core

! todos_repository_simple 0.0.0 from git https://github.com/felangel/flutter_architecture_samples at 71f32b in todos_repository_simple
Running "flutter pub get" in bloc_todoapp2...                       1.0s
Process finished with exit code 0

@huynguyennovem exit code 0 means everything went well ๐Ÿ˜Š

@huynguyennovem exit code 0 means everything went well ๐Ÿ˜Š

oh, sorry about that and thank for your support!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sawankumarbundelkhandi picture sawankumarbundelkhandi  ยท  108Comments

fvisticot picture fvisticot  ยท  31Comments

felangel picture felangel  ยท  27Comments

felangel picture felangel  ยท  35Comments

hahai96 picture hahai96  ยท  40Comments