pub get failed : A package may not list itself as a dependency
Asked Answered
B

3

18

I'm having this problem in pubspec.yaml :

here the pubspec.yaml :

 dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  pluto_grid: ^2.9.3

and here is the Error :

[pluto_grid] flutter pub get
Running "flutter pub get" in pluto_grid...                      
Error on line 37, column 3 of pubspec.yaml: A package may not list itself as a dependency.
   ╷
37 │   pluto_grid: ^2.9.3
   │   ^^^^^^^^^^
   ╵
pub get failed (65;    ╵)
exit code 65

need to know what's wrong, used the same in other project and worked perfectly.

Bowleg answered 14/4, 2022 at 11:44 Comment(0)
B
86

I found why i'm getting this Error, this happens because the project name is the same as the library name. so if you have the same Error as this just try to change the project name.

Bowleg answered 14/4, 2022 at 11:55 Comment(4)
The error message told you exactly what was wrong. Was the message confusing? How could it be improved?Leptorrhine
@Leptorrhine Maybe something like Mosayeb Masoumi's answer can improve the message.Lovett
Why would someone name their project the same as one of its dependencies?Leptorrhine
did the same mistake with project name 'hive' 🙄Calc
A
9

the project package name should not be the same name of added library's name in pubspec.yaml

Almita answered 18/5, 2022 at 11:9 Comment(0)
B
1

That's not necessary to declare your own project as a dependency in the project's pubspec.yaml

Brawley answered 14/4, 2022 at 12:8 Comment(1)
i didn't notice first time that my project name was the same as the library name. i was so confused why i was getting the Error.Bowleg

© 2022 - 2025 — McMap. All rights reserved.