pub icon indicating copy to clipboard operation
pub copied to clipboard

Better error message when path dependencies cannot be found

Open dcharkes opened this issue 3 years ago • 3 comments

It looks like pub somehow refuses to find pubspec.yaml in the temp folder.

Temp folder:

PS C:\Users\dacoharkes\AppData\Local\Temp\pkg_dartdev_test72e16586\dart_app> cat .\pubspec.yaml
name: dart_app

environment:
  sdk: ">=2.18.0 <3.0.0"

dependencies:
  my_native_library:
    path: ../my_native_library
  my_native_library2:
    path: ../my_native_library2
PS C:\Users\dacoharkes\AppData\Local\Temp\pkg_dartdev_test72e16586\dart_app> dart pub get
Resolving dependencies...
Could not find a file named "pubspec.yaml" in "C:\Users\dacoharkes\AppData\Local".

Identical project not in temp folder:

PS C:\src\dart-sdk\sdk\pkg\native\test\test_projects\dart_app> dart pub get
Resolving dependencies...
Got dependencies!
PS C:\src\dart-sdk\sdk\pkg\native\test\test_projects\dart_app> cat .\pubspec.yaml
name: dart_app

environment:
  sdk: ">=2.18.0 <3.0.0"

dependencies:
  my_native_library:
    path: ../my_native_library
  my_native_library2:
    path: ../my_native_library2

dcharkes avatar Nov 18 '22 15:11 dcharkes

Ah, the referred pubspec.yaml contains a path dependency that was not properly string-replaced on Windows by my tests...

dcharkes avatar Nov 18 '22 15:11 dcharkes

So could we have given a more precise error message?

sigurdm avatar Nov 21 '22 08:11 sigurdm

Yes, mentioning not just the path that was being searched for, but also what caused us to search for that:

  • path not found (currently in error message)
  • pubspec.yaml path that caused us to search there, which might not be the one of the root package. (add to error message)
  • contents of pubspec.yaml that caused us to search there, just for convenience so that you don't have to browse to the dependencies -> <package_name> -> path yourself to realize why this is happening. [You'll still have got go there to rectify the issue.] (add to error message)

dcharkes avatar Nov 21 '22 09:11 dcharkes