Misleading error message when git dependency name doesn't match
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"
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 :)
I've just had to deal with this error as well. It was rather hard to find the problem.
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
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.
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.
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.
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.
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.