in lib/src/entrypoint.dart [259:347]
Future<void> acquireDependencies(
SolveType type, {
Iterable<String>? unlock,
bool dryRun = false,
bool precompile = false,
required bool generateDotPackages,
required PubAnalytics? analytics,
bool onlyReportSuccessOrFailure = false,
}) async {
final suffix = root.isInMemory || root.dir == '.' ? '' : ' in ${root.dir}';
SolveResult result;
try {
result = await log.progress('Resolving dependencies$suffix', () async {
_checkSdkConstraint(root.pubspec);
return resolveVersions(
type,
cache,
root,
lockFile: lockFile,
unlock: unlock ?? [],
);
});
} catch (e) {
if (onlyReportSuccessOrFailure && (e is ApplicationException)) {
final directoryOption = root.isInMemory || root.dir == '.'
? ''
: ' --directory ${root.dir}';
throw ApplicationException(
'Resolving dependencies$suffix failed. For details run `$topLevelProgram pub ${type.toString()}$directoryOption`');
} else {
rethrow;
}
}
// Log once about all overridden packages.
if (warnAboutPreReleaseSdkOverrides) {
var overriddenPackages = (result.pubspecs.values
.where((pubspec) => pubspec.dartSdkWasOverridden)
.map((pubspec) => pubspec.name)
.toList()
..sort())
.join(', ');
if (overriddenPackages.isNotEmpty) {
log.message(log.yellow(
'Overriding the upper bound Dart SDK constraint to <=${sdk.version} '
'for the following packages:\n\n$overriddenPackages\n\n'
'To disable this you can set the PUB_ALLOW_PRERELEASE_SDK system '
'environment variable to `false`, or you can silence this message '
'by setting it to `quiet`.'));
}
}
if (!onlyReportSuccessOrFailure) {
await result.showReport(type, cache);
}
if (!dryRun) {
await result.downloadCachedPackages(cache);
_saveLockFile(result);
}
if (onlyReportSuccessOrFailure) {
log.message('Got dependencies$suffix.');
} else {
await result.summarizeChanges(type, cache, dryRun: dryRun);
}
if (!dryRun) {
if (analytics != null) {
result.sendAnalytics(analytics);
}
/// Build a package graph from the version solver results so we don't
/// have to reload and reparse all the pubspecs.
_packageGraph = PackageGraph.fromSolveResult(this, result);
await writePackagesFiles(generateDotPackages: generateDotPackages);
try {
if (precompile) {
await precompileExecutables();
} else {
_deleteExecutableSnapshots(changed: result.changedPackages);
}
} catch (error, stackTrace) {
// Just log exceptions here. Since the method is just about acquiring
// dependencies, it shouldn't fail unless that fails.
log.exception(error, stackTrace);
}
}
}