Build: Could not find package "build_runner". Did you forget to add a dependency?

Created on 18 Dec 2019  路  6Comments  路  Source: dart-lang/build

Thank you for taking the time to file an issue!

In order to route, prioritize, and act on this as soon as possible please include:

  • Dart SDK Version (dart --version)
    Dart VM version: 2.7.0 (Fri Dec 6 16:26:51 2019 +0100) on "windows_x64"
  • What package(s) from this repo you are using, and the version (i.e. build_runner 0.7.12)
    build_runner: ^1.7.2

    I implement Modularization in my project. first i create packages with name network with run command flutter create --template=package network, i reference this.
    This packages include models of my project. after that i create model user ,then run command build the model flutter packages pub run build_runner build --delete-conflicting-outputs :

import 'package:hive/hive.dart';

part 'user_model_hive.g.dart';

@HiveType()
class UserModelHive extends HiveObject {
  @HiveField(0) 
  DateTime id;
  @HiveField(1)
  String giverName;
  @HiveField(2)
  String pinCodeNumber;

  UserModelHive({this.id, this.giverName, this.pinCodeNumber});
}

But i get error like this
```
Could not find package "build_runner". Did you forget to add a dependency?
pub finished with exit code 65

i'm sure already include build_runner in my packages network pubspec.yaml.

name: network
description: A new Flutter package project.
version: 0.0.1
author:
homepage:

environment:
sdk: ">=2.1.0 <3.0.0"

dependencies:
flutter:
sdk: flutter
hive: ^1.1.1
hive_flutter: ^0.2.1
dev_dependencies:
flutter_test:
sdk: flutter
hive_generator: ^0.5.2
build_runner: ^1.7.2

For information on the generic Dart part of this file, see the

following page: https://dart.dev/tools/pub/pubspec

The following section is specific to Flutter.

flutter:
# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages
```

It's my structure Folder if you needed.

Most helpful comment

You definitely have the build_runner dependency. Maybe you are running from the wrong directory? You need to run from the network directory not your root.

All 6 comments

What does your .packages file look like?

This is my .packages :

# Generated by pub on 2019-12-18 23:23:21.354104.
_fe_analyzer_shared:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-1.0.1/lib/
analyzer:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.39.2+1/lib/
archive:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/archive-2.0.11/lib/
args:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.5.2/lib/
async:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.4.0/lib/
boolean_selector:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.5/lib/
build:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/build-1.2.2/lib/
build_config:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/build_config-0.4.1+1/lib/
build_daemon:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/build_daemon-2.1.2/lib/
build_resolvers:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/build_resolvers-1.3.0/lib/
build_runner:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/build_runner-1.7.2/lib/
build_runner_core:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/build_runner_core-4.3.0/lib/
built_collection:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/built_collection-4.3.0/lib/
built_value:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/built_value-7.0.0/lib/
charcode:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/
checked_yaml:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/checked_yaml-1.0.2/lib/
code_builder:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/code_builder-3.2.1/lib/
collection:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
convert:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/convert-2.1.1/lib/
crypto:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-2.1.3/lib/
csslib:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/csslib-0.16.1/lib/
dart_style:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.3/lib/
fixnum:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/fixnum-0.10.11/lib/
flutter:file:///C:/flutter/flutter/packages/flutter/lib/
flutter_test:file:///C:/flutter/flutter/packages/flutter_test/lib/
glob:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/glob-1.2.0/lib/
graphs:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/graphs-0.2.0/lib/
hive:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.1.1/lib/
hive_flutter:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive_flutter-0.2.1/lib/
hive_generator:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/hive_generator-0.5.2/lib/
html:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/html-0.14.0+3/lib/
http:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/
http_multi_server:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/http_multi_server-2.1.0/lib/
http_parser:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/http_parser-3.1.3/lib/
image:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/image-2.1.4/lib/
io:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/io-0.3.3/lib/
js:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.1+1/lib/
json_annotation:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/json_annotation-3.0.0/lib/
logging:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/logging-0.11.3+2/lib/
matcher:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.6/lib/
meta:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.8/lib/
mime:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mime-0.9.6+3/lib/
node_interop:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/node_interop-1.0.3/lib/
node_io:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/node_io-1.0.1+2/lib/
package_config:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_config-1.1.0/lib/
package_resolver:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_resolver-1.0.10/lib/
path:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.4/lib/
pedantic:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.8.0+1/lib/
petitparser:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/petitparser-2.4.0/lib/
pointycastle:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/pointycastle-1.0.2/lib/
pool:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/pool-1.4.0/lib/
pub_semver:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/pub_semver-1.4.2/lib/
pubspec_parse:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/pubspec_parse-0.1.5/lib/
quiver:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.5/lib/
shelf:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shelf-0.7.5/lib/
shelf_web_socket:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.3/lib/
sky_engine:file:///C:/flutter/flutter/bin/cache/pkg/sky_engine/lib/
source_gen:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/source_gen-0.9.4+6/lib/
source_span:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.5/lib/
stack_trace:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/
stream_channel:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.0.0/lib/
stream_transform:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/stream_transform-0.0.20/lib/
string_scanner:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.5/lib/
term_glyph:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/
test_api:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.11/lib/
timing:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/timing-0.1.1+2/lib/
typed_data:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
vector_math:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/
watcher:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/watcher-0.9.7+13/lib/
web_socket_channel:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-1.1.0/lib/
xml:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/xml-3.5.0/lib/
yaml:file:///C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/yaml-2.2.0/lib/
network:lib/

You definitely have the build_runner dependency. Maybe you are running from the wrong directory? You need to run from the network directory not your root.

@jakemac53 After move to network directory , It's solved the problem!. Thank's.
I can close the issue now.

You definitely have the build_runner dependency. Maybe you are running from the wrong directory? You need to run from the network directory not your root.

I'm having the same problem. What do you mean by "need to run from the network directory"? and does your answer apply to a Linux system?
image

network was just the name of the directory that their package lived in.

You need to run from the directory where your pubspec.yaml lives for your package.

Was this page helpful?
0 / 5 - 0 ratings