【问题标题】:Should .packages files be auto-generated for pub packages cached from git?应该为从 git 缓存的 pub 包自动生成 .packages 文件吗?
【发布时间】:2021-01-17 20:25:24
【问题描述】:

我问它的原因是我正在开发一个包,实际上是颤振插件,当我在我的应用程序 pubspec.yaml 使用路径本地引用它时:一切正常,我可以看到一个 .packages 文件正在在本地插件 workdir 中生成。现在,如果我现在尝试使用 git 引用插件:在我的应用程序 pubspec 中,flutter pub get 很高兴 但是 当我尝试运行应用程序时,构建失败并显示错误消息:

Launching lib/main.dart on XYZ in debug mode...
/home/maksimlin/.pub-cache/git/edit_exif-3c87efc135c1269b5961ff73696a19e988132ad7/.packages does not exist.
Did you run "flutter pub get" in this directory?


FAILURE: Build failed with an exception.

* Where:
Script '/home/maksimlin/fvm/versions/dev/packages/flutter_tools/gradle/flutter.gradle' line: 896

* What went wrong:
Execution failed for task ':edit_exif:compileFlutterBuildDebug'.
> Process 'command '/home/maksimlin/fvm/versions/dev/bin/flutter'' finished with non-zero exit value 1

如果我将 .packages 自动生成的文件从本地插件 workdir 复制到 pub-cache 位置,我的应用程序构建得很好 那么 pub 自动生成 .packages 以从 git 包中缓存有什么问题吗?还是我的插件做错了什么?

不幸的是,我似乎找不到太多(任何)关于 .package 文件使用的文档,尤其是缓存包。

【问题讨论】:

  • 原来我错误地在导致这个问题的插件 gradle 配置中添加了一些额外的配置:``` def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties' ) if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("未找到 Flutter SDK。在 local.properties 文件中使用 flutter.sdk 定义位置。") } ``

标签: flutter dart flutter-dependencies dart-pub


【解决方案1】:
# Generated by pub on 2020-10-01 15:23:17.745081.
args:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.6.0/lib/
bloc:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/bloc-4.0.0/lib/
characters:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0-nullsafety.2/lib/
charcode:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.3/lib/
charts_common:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/charts_common-0.9.0/lib/
cloud_firestore:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.14.0/lib/
cloud_firestore_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_platform_interface-2.0.0/lib/
cloud_firestore_web:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-0.2.0/lib/
collection:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0-nullsafety.2/lib/
convert:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/convert-2.1.1/lib/
crypto:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-2.1.5/lib/
custom_switch:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/custom_switch-0.0.1/lib/
dio:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/dio-3.0.10/lib/
easy_localization:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/easy_localization-2.3.3/lib/
file:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/file-5.2.1/lib/
firebase:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-7.3.0/lib/
firebase_auth:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.18.0/lib/
firebase_auth_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-2.0.0/lib/
firebase_auth_web:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-0.3.0/lib/
firebase_core:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.5.0/lib/
firebase_core_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-2.0.0/lib/
firebase_core_web:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_web-0.2.0/lib/
flutter:file:///C:/Src/flutter/packages/flutter/lib/
flutter_bloc:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_bloc-4.0.1/lib/
flutter_localizations:file:///C:/Src/flutter/packages/flutter_localizations/lib/
flutter_web_plugins:file:///C:/Src/flutter/packages/flutter_web_plugins/lib/
google_fonts:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/google_fonts-1.1.0/lib/
http:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.2/lib/
http_parser:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/http_parser-3.1.4/lib/
intl:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.16.1/lib/
js:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.2/lib/
logging:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/logging-0.11.4/lib/
matcher:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.9/lib/
material_design_icons_flutter:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/material_design_icons_flutter-4.0.5245/lib/
meta:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.2/lib/
nested:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/nested-0.0.4/lib/
path:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety/lib/
path_provider:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/lib/
path_provider_linux:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/lib/
path_provider_macos:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/lib/
path_provider_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_platform_interface-1.0.2/lib/
pedantic:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.9.2/lib/
platform:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/platform-2.2.1/lib/
plugin_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/plugin_platform_interface-1.0.2/lib/
process:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/process-3.0.13/lib/
provider:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/provider-4.3.2/lib/
quiver:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.3/lib/
shared_preferences:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.8/lib/
shared_preferences_linux:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-0.0.2+1/lib/
shared_preferences_macos:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+10/lib/
shared_preferences_platform_interface:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_platform_interface-1.0.4/lib/
shared_preferences_web:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/lib/
sky_engine:file:///C:/Src/flutter/bin/cache/pkg/sky_engine/lib/
source_span:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.7.0/lib/
stack_trace:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.5/lib/
string_scanner:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.5/lib/
term_glyph:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/
typed_data:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0-nullsafety.2/lib/
vector_math:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0-nullsafety.2/lib/
xdg_directories:file:///C:/Src/flutter/.pub-cache/hosted/pub.dartlang.org/xdg_directories-0.1.0/lib/
website:lib/

这是我的.package 文件,你可以看到这里有我用过的每个包以及目录(file:///C:/Src/flutter 是我的目录)。

.package 是一个自动生成的文件,因此您可以删除旧文件并运行 flutter pub get 以便生成新文件。

【讨论】:

  • 谢谢,但这并不是真正回答我的问题。我知道什么。包文件看起来像。我特别想知道是否应该有一个自动生成的 .包文件 inside .pub-cache 中的包的缓存版本,我从 git repo 包含在我的应用程序中。
  • 它只是包的库位置以及一些材料和 Cupertino 小部件的路径。
  • 显然它是本地缓存包的位置列表,我的问题实际上是关于是否应该为从 git inisde .pub-cache 缓存的包自动生成它?如果是,为什么不在我的情况下?
  • .packages 文件在 GitHub 存储库中不存在,因为在 .gitignore 中提到了此文件。
猜你喜欢
  • 1970-01-01
  • 2023-04-08
  • 1970-01-01
  • 1970-01-01
  • 2021-07-01
  • 1970-01-01
  • 2023-03-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多