I downloaded the Mockito library (https://pub.dev/packages/mockito) and followed the instruction to use "dart run build_runner build" to generate mocks in my project directory and it failed with the following error.
Could not find a file named "pubspec.yaml" in "/Users/mark/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-31.0.0".
#0 new Pubspec.load (package:pub/src/pubspec.dart:288:7)
#1 new Package.load (package:pub/src/package.dart:149:27)
#2 SystemCache.load (package:pub/src/system_cache.dart:113:20)
#3 Entrypoint._createPackageGraph (package:pub/src/entrypoint.dart:112:63)
#4 Entrypoint.packageGraph (package:pub/src/entrypoint.dart:107:54)
#5 getExecutableForCommand (package:pub/src/executable.dart:338:19)
#6 RunCommand.run (package:dartdev/src/commands/run.dart:232:32)
#7 CommandRunner.runCommand (package:args/command_runner.dart:209:27)
#8 DartdevRunner.runCommand (package:dartdev/dartdev.dart:232:30)
#9 CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:119:25)
#10 new Future.sync (dart:async/future.dart:296:31)
#11 CommandRunner.run (package:args/command_runner.dart:119:14)
#12 runDartdev (package:dartdev/dartdev.dart:67:29)
#13 main (file:///opt/s/w/ir/cache/builder/sdk/pkg/dartdev/bin/dartdev.dart:11:9)
#14 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:293:32)
#15 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
However if I followed the instructions in Flutter's cookbook(https://docs.flutter.dev/cookbook/testing/unit/mocking#3-create-a-test-file-with-a-mock-httpclient) and used "flutter pub run build_runner build" in the project directory it works.
What are the differences between dart run and flutter pub run? Why dart run tries to execute from the /Users/username/.pub-cache directory when I am executing it from the project directory?
I saw this related issue in Mockit, however it does not explain the differences. (https://github.com/dart-lang/mockito/issues/435)