felangel / bloc

A predictable state management library that helps implement the BLoC design pattern
https://bloclibrary.dev
MIT License
11.79k stars 3.39k forks source link

[flutter_todos] flutter get packages fail. #151

Closed nosmirck closed 5 years ago

nosmirck commented 5 years ago

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

3. 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>

felangel commented 5 years ago

@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! 👍

nosmirck commented 5 years ago

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
nosmirck commented 5 years ago

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

felangel commented 5 years ago

@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
nosmirck commented 5 years ago

@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.

felangel commented 5 years ago

@nosmirck did you try the latest pubspec.yaml?

nosmirck commented 5 years ago

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)
felangel commented 5 years ago

@nosmirck did you delete your pubspec.lock?

I just created a clean project and tested it and it seems to work for me. 🤔

nosmirck commented 5 years ago

Just did, same error.

felangel commented 5 years ago

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?

nosmirck commented 5 years ago

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)

felangel commented 5 years ago

@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 👍

nosmirck commented 5 years ago

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.

felangel commented 5 years ago

@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.

nosmirck commented 5 years ago

Perfect! good solution.

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

felangel commented 5 years ago

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

felangel commented 5 years ago

FYI: I opened https://github.com/brianegan/flutter_architecture_samples/pull/124 to address this 🤞

rahi0 commented 5 years ago

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

this is what I got

felangel commented 5 years ago

@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 👍

huynguyennovem commented 4 years ago

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

felangel commented 4 years ago

@huynguyennovem can you describe the steps you're taking and the error you're getting? Thanks 👍

huynguyennovem commented 4 years ago

@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

felangel commented 4 years ago

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

huynguyennovem commented 4 years ago

@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.

felangel commented 4 years ago

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

huynguyennovem commented 4 years ago

Please check it : https://github.com/huynguyennovem/FlutterTodoAppSample

felangel commented 4 years ago

@huynguyennovem just tried and had no trouble 🤔 Have you tried clearing your pub cache?

huynguyennovem commented 4 years ago

@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
felangel commented 4 years ago

@huynguyennovem exit code 0 means everything went well 😊

huynguyennovem commented 4 years ago

@huynguyennovem exit code 0 means everything went well 😊

oh, sorry about that and thank for your support!

MohammedSalehelShazly commented 1 year ago

I have the same problem in another repo and package, fleather I solve it with these steps, (I know it's not logic but it solves it). I understand that the first package depends on the second.

  1. Install parchment (the second) package
  2. Install fleather (the first) package It makes an error: failed Because every version of fleather from git depends on parchment from the path and nodebook_editor depends on parchment from git, fleather from git is forbidden.
  3. remove parchment package
  4. finally, install fleather package

it solves the problem.