Give full error even in summary mode (#3804)
diff --git a/lib/src/entrypoint.dart b/lib/src/entrypoint.dart index 988c655..afd6c8a 100644 --- a/lib/src/entrypoint.dart +++ b/lib/src/entrypoint.dart
@@ -339,15 +339,6 @@ summaryOnly = summaryOnly || _summaryOnlyEnvironment; final suffix = root.isInMemory || root.dir == '.' ? '' : ' in ${root.dir}'; - String forDetails() { - if (!summaryOnly) return ''; - final enforceLockfileOption = - enforceLockfile ? ' --enforce-lockfile' : ''; - final directoryOption = - root.isInMemory || root.dir == '.' ? '' : ' --directory ${root.dir}'; - return ' For details run `$topLevelProgram pub ${type.toString()}$directoryOption$enforceLockfileOption`'; - } - if (enforceLockfile && !fileExists(lockFilePath)) { throw ApplicationException(''' Retrieving dependencies failed$suffix. @@ -357,26 +348,16 @@ } 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 (summaryOnly && (e is ApplicationException)) { - throw ApplicationException( - 'Resolving dependencies$suffix failed.${forDetails()}', - ); - } else { - rethrow; - } - } + result = await log.progress('Resolving dependencies$suffix', () async { + _checkSdkConstraint(root.pubspec); + return resolveVersions( + type, + cache, + root, + lockFile: lockFile, + unlock: unlock ?? [], + ); + }); // We have to download files also with --dry-run to ensure we know the // archive hashes for downloaded files. @@ -397,13 +378,11 @@ final hasChanges = await report.show(); await report.summarize(); if (enforceLockfile && hasChanges) { - var suggestion = summaryOnly - ? '' - : ''' -\n\nTo update `$lockFilePath` run `$topLevelProgram pub get`$suffix without -`--enforce-lockfile`.'''; dataError(''' -Unable to satisfy `$pubspecPath` using `$lockFilePath`$suffix.${forDetails()}$suggestion'''); +Unable to satisfy `$pubspecPath` using `$lockFilePath`$suffix. + +To update `$lockFilePath` run `$topLevelProgram pub get`$suffix without +`--enforce-lockfile`.'''); } if (!(dryRun || enforceLockfile)) {
diff --git a/test/get/enforce_lockfile_test.dart b/test/get/enforce_lockfile_test.dart index ab66ecb..136b8df 100644 --- a/test/get/enforce_lockfile_test.dart +++ b/test/get/enforce_lockfile_test.dart
@@ -78,7 +78,7 @@ final example = p.join('.', 'example'); final examplePubspec = p.join('example', 'pubspec.yaml'); - final exampleLockfile = p.join('example', 'pubspec.lock'); + final examplePubspecLock = p.join('example', 'pubspec.lock'); await pubGet( args: ['--enforce-lockfile', '--example'], @@ -86,8 +86,13 @@ contains('Got dependencies!'), contains('Resolving dependencies in $example...'), ), - error: contains( - 'Unable to satisfy `$examplePubspec` using `$exampleLockfile` in $example. For details run `dart pub get --directory $example --enforce-lockfile', + error: allOf( + contains( + 'Unable to satisfy `$examplePubspec` using `$examplePubspecLock` in $example.', + ), + contains( + 'To update `$examplePubspecLock` run `dart pub get` in $example without\n' + '`--enforce-lockfile`.'), ), exitCode: DATA, );
diff --git a/test/get/gets_in_example_folder_test.dart b/test/get/gets_in_example_folder_test.dart index b0aee35..c823303 100644 --- a/test/get/gets_in_example_folder_test.dart +++ b/test/get/gets_in_example_folder_test.dart
@@ -6,6 +6,7 @@ import 'package:path/path.dart' as p; import 'package:pub/src/exit_codes.dart' as exit_codes; +import 'package:pub/src/exit_codes.dart'; import 'package:test/test.dart'; import '../descriptor.dart' as d; @@ -43,7 +44,7 @@ args: ['--example'], output: command.name == 'get' ? ''' -Resolving dependencies... +Resolving dependencies... Got dependencies! Resolving dependencies in $dotExample... Got dependencies in $dotExample.''' @@ -57,7 +58,7 @@ expect(exampleLockFile.existsSync(), true); }); - test('Failures are met with a suggested command', () async { + test('Failures are not summarized', () async { await d.dir(appPath, [ d.appPubspec(), d.dir('example', [ @@ -72,9 +73,9 @@ await pubGet( args: ['--example'], error: contains( - 'Resolving dependencies in $dotExample failed. For details run `dart pub get --directory $dotExample`', + 'Error on line 1, column 9 of example${p.separator}pubspec.yaml', ), - exitCode: 1, + exitCode: DATA, ); await pubGet( args: ['--directory', dotExample],