$ flutter pub run build_runner build -o web:build --delete-conflicting-outputs --no-release
with error message:pub run build_runner serve • 5550 • STDERR • No .dart_tool/package_config.json file found, please run "pub get" first.
dart --version)2.6.0-dev.8.2.flutter-d50c158d42
build_runner 0.7.12)pubspec.lock file._build_runner-1.7.2**
none
Tests fail both on MacOS & Linux
not applicable
tagging in:
@grouma
@jacob314
@jonahwilliams
@jakemac53
This is not supposed to be a required file.
cc @jonasfj @sigurdm I am transferring this issue to the pub repo
Fwiw the bug here looks to be that the newer pub requires a .dart_tool/package_config.json but you may not have ran a pub get yet after upgrading your sdk.
pub run checks that:
pubspec.lock satisfies pubspec.yaml, and.packages is up-to-date with pubspec.lock and (as of recently),.dart_tool/package_config.json exists and is up-to-date with pubspec.lock (and path dependencies).Doing pub get should resolve this issue, @albertusangga is that not the case?
Does any one have a suggestion for a better error message that would convince the user to run pub get again. I'm sure more users will raise this question, so any clarification we can do in the message will likely help many users.
Maybe the .dart_tool/package_config.json part is confusing people? We could hide the details of that behind the --verbose flag and instead make an assumption that they just updated their sdk and need to re-run pub get. In that case the error message would be something like:
Your sdk has been updated since the last run - please re-run "pub get"
I think pub may already record the previous sdk version as well so we could check for this scenario more directly?
Are we supposed to manually run pub get instead of flutter pub get?
We do run flutter pub get though before running the build_runner (which is triggered by running flutter test)
If you have the dart and flutter sdks things definitely might get more complicated here... but in general I think you would need to use the sdk that you want to run pub run with.
So if you use flutter pub run then you need to do flutter pub get and those things should be compatible. It is possible this doesn't actually work as you would expect today.
Yes that is what we do, running flutter pub get before triggering flutter pub run build_runner build -o web:build --delete-conflicting-outputs --no-release, and it seems to be not working.
Any idea on how to fix this?
That is very weird, maybe @jonasfj would have some ideas. As long as the pub version is consistent it should work.
You could try manually deleting your pubspec.lock file just in case... maybe it thinks everything is up to date and isn't recreating those files.
Ok I think I know the root cause for our error now.
This is caused by our integration test running flutter clean first (which ended up deleting the .dart_tool folder before executing the flutter pub run build_runner ...), but this works fine before the Flutter's dart SDK version updates to 2.6.0-dev.8.2.flutter-d50c158d42.
If I'm correct, I think there is a change in the latest dart SDK that prevented running pub get automatically? Because I tried this with earlier dart sdk, running flutter clean and then trying to run pub run directly without pub get seems to work fine.
Is this correct?
Ahhh this makes sense. The difference is that previously deleting the .dart_tool directory at any point was perfectly fine to do (pub only put precompiled binaries in there). Now that means you have to re-run pub get.
There are a few potential resolutions here:
flutter clean delete only specific sub-directories of .dart_toolflutter clean could delete the .packages fileflutter clean could re-run flutter pub getpub similar to what I suggested above..dart_tool/ dir or anything under it so removing that from the message would be less confusing.In general I think we should focus on the error messages from pub and improving that. I think it is totally fine and intuitive that you have to do a new flutter pub get after doing a flutter clean. The main question then is how to present that to the user.
In general I think we should focus on the error messages from pub and improving that. I think it is totally fine and intuitive that you have to do a new
flutter pub getafter doing aflutter clean. The main question then is how to present that to the user.
I agree.
The contract for flutter clean is just that it deletes those directories, not that it is safe to build again without running pub get first.
We hit this in an uncommon case where we're using the flutter tool to call pub run after the clean. Our real confusion here is that it did work, and then it stopped working.
So long as the error is just that pub get needs to be re-run, and the error message communicates that, I am OK with closing this issue as intended behavior.
I'll close this as intended behavior.
What is the workaround? When I run pub run build_runner build instead of flutter pub run build_runner build I get: The Flutter SDK is not available. But if I run it with flutter at the start I get: The pubspec.yaml file has changed since the pubspec.lock file was generated, please run "pub get" again.
pub finished with exit code 65.
I have been stuck on this for hours.
Are you using generate: true and flutter_gen, see https://github.com/flutter/flutter/issues/73870
@jonasfj I'm not using generate: anywhere. I am using flutter_gen though:
flutter_gen:
output: lib/
version (just updated to see if it fixed it): flutter_gen: ^2.0.1
adding --verbose to flutter pub run build_runner build:
[ +114 ms] executing: [/Users/benjaminfarquhar/development/flutter/] git -c log.showSignature=false log -n 1
--pretty=format:%H
[ +71 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[ ] c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
[ ] executing: [/Users/benjaminfarquhar/development/flutter/] git tag --points-at
c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
[ +27 ms] Exit code 0 from: git tag --points-at c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
[ ] 2.0.1
[ +59 ms] executing: [/Users/benjaminfarquhar/development/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +15 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/stable
[ ] executing: [/Users/benjaminfarquhar/development/flutter/] git ls-remote --get-url origin
[ +15 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +71 ms] executing: [/Users/benjaminfarquhar/development/flutter/] git rev-parse --abbrev-ref HEAD
[ +30 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ ] stable
[ +9 ms] executing: sw_vers -productName
[ +21 ms] Exit code 0 from: sw_vers -productName
[ ] macOS
[ ] executing: sw_vers -productVersion
[ +20 ms] Exit code 0 from: sw_vers -productVersion
[ ] 11.2.2
[ ] executing: sw_vers -buildVersion
[ +24 ms] Exit code 0 from: sw_vers -buildVersion
[ ] 20D80
[ +9 ms] executing: sysctl hw.optional.arm64
[ +12 ms] Exit code 1 from: sysctl hw.optional.arm64
[ ] sysctl: unknown oid 'hw.optional.arm64'
[ +98 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +4 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +58 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +49 ms] Using /Users/benjaminfarquhar/development/flutter/.pub-cache for the pub cache.
[ ] executing: /Users/benjaminfarquhar/development/flutter/bin/cache/dart-sdk/bin/pub run build_runner --verbose
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again.
[ +621 ms] "flutter run" took 755ms.
[ +24 ms] pub finished with exit code 65
[ +17 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:364:7)
<asynchronous suspension>
#2 PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:238:5)
<asynchronous suspension>
#3 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1157:12)
<asynchronous suspension>
#4 FlutterCommand.run.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command.dart:1009:27)
<asynchronous suspension>
#5 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#6 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#7 CommandRunner.runCommand (package:args/command_runner.dart:197:13)
<asynchronous suspension>
#8 FlutterCommandRunner.runCommand.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command_runner.dart:278:9)
<asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#10 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#11 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:234:5)
<asynchronous suspension>
#12 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
<asynchronous suspension>
#13 run.<anonymous closure> (package:flutter_tools/runner.dart:62:12)
<asynchronous suspension>
#14 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#15 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#16 runInContext (package:flutter_tools/src/context_runner.dart:73:10)
<asynchronous suspension>
#17 main (package:flutter_tools/executable.dart:90:3)
<asynchronous suspension>
[ +265 ms] ensureAnalyticsSent: 254ms
[ +3 ms] Running shutdown hooks
[ ] Shutdown hooks complete
[ ] exiting with code 65
@BenjaminFarquhar, try digging into flutter_tools it looks like something is modifying your pubspec.yaml.
I think this is an orthogonal flutter issue, if not related to flutter_gen.
Most helpful comment
Are we supposed to manually run
pub getinstead offlutter pub get?We do run
flutter pub getthough before running the build_runner (which is triggered by runningflutter test)