pub icon indicating copy to clipboard operation
pub copied to clipboard

Misleading error message when git dependency name doesn't match

Open PhilipRoman opened this issue 7 years ago • 10 comments

Contents of pubspec.yaml:

name: my_package
dependencies:
  wrong_name:
    git: git://github.com/user/different_name.git

Running

$ pub get

fails with exit code 65 and a misleading error message:

Resolving dependencies...
Error on line 1, column 7: "name" field doesn't match expected name "wrong_name".
name: different_name
      ^^^^^^^^^^^^^^

The error message indicates an error on line 1, which would mean there is an issue with the name of my_package. This is completely wrong as the actual error is that dependency wrong_name points to a Dart project with package name different_name.

Software Versions

$ pub --version
Pub 2.2.0
$ dart --version
Dart VM version: 2.2.0 (Unknown timestamp) on "linux_x64"

PhilipRoman avatar Mar 10 '19 16:03 PhilipRoman

The error message indicates an error on line 1, which would mean there is an issue with the name of my_package.

Actually, the error is on line 1 of the package downloaded from git://github.com/user/different_name.git.

From a user perspective it probably makes more sense to phrase it differently :) But I can't help wondering if the code doing this is the same that verifies the pubspec.yaml in your current folder...

I agree that this could be better :)

jonasfj avatar Mar 12 '19 18:03 jonasfj

I've just had to deal with this error as well. It was rather hard to find the problem.

bsutton avatar Apr 01 '20 10:04 bsutton

I have the same in my plugin I just used the following

flutter clean
flutter pub get

but you maybe refer to a different case

amorenew avatar Jul 28 '20 19:07 amorenew

I'm just stuck with this issue. I have renamed both directory and package name of one my git repos, after the change it was working actually, now days passed and can't run pub get/upgrade.

Even removing the problematic package from pubspec.yaml does not solve the issue. As I said, it's just stucked.

Edit: If I remove the other specific git package, it works ¯\_(ツ)_/¯ . The case because the version before rename was also imported in that package. That's the error.

The error message does not indicates properly which dependency causes the problem.

esenmx avatar Apr 14 '22 09:04 esenmx

I've stuck with this issue as well, in my case I created new module and copy/pasted my other module yaml file with all dependencies, but forgot to change 'name' value inside yaml file, which ended in having two same named modules and flutter giving me the same error.

MitsuraIvan avatar Jul 22 '22 12:07 MitsuraIvan

I also just hit this error and was very confused. :) As others have noted, when you hit this the error is not in the pubspec.yaml that pub is pointing to, but rather the pubspec.yaml that is depending on that package.

eseidel avatar Jun 25 '23 13:06 eseidel

I understand that this issue is closed, but I don't think it should be. This issue hit me today and I only fixed it because of this thread. It would be very helpful if the error message could at least report what file it was found in. In my case it was about 3 dependencies deep.

0xNF avatar Sep 12 '23 08:09 0xNF

Sorry - I made a fix, but had to revert and forgot to reopen the issue.

I still want to fix this, but it has to be done a bit differently.

sigurdm avatar Sep 13 '23 07:09 sigurdm