Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
6abd3691
Unverified
Commit
6abd3691
authored
Jul 21, 2022
by
Christopher Fujino
Committed by
GitHub
Jul 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] add more debugging when pub get fails (#108062)
parent
092481d4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
14 deletions
+41
-14
pub.dart
packages/flutter_tools/lib/src/dart/pub.dart
+29
-12
pub_get_test.dart
...s/flutter_tools/test/general.shard/dart/pub_get_test.dart
+12
-2
No files found.
packages/flutter_tools/lib/src/dart/pub.dart
View file @
6abd3691
...
...
@@ -266,17 +266,10 @@ class _DefaultPub implements Pub {
}
catch
(
exception
)
{
// ignore: avoid_catches_without_on_clauses
status
?.
cancel
();
if
(
exception
is
io
.
ProcessException
)
{
final
StringBuffer
buffer
=
StringBuffer
(
exception
.
message
);
final
StringBuffer
buffer
=
StringBuffer
(
'
${exception.message}
\n
'
);
buffer
.
writeln
(
'Working directory: "
$directory
"'
);
final
Map
<
String
,
String
>
env
=
await
_createPubEnvironment
(
context
,
flutterRootOverride
);
if
(
env
.
entries
.
isNotEmpty
)
{
buffer
.
writeln
(
'pub env: {'
);
for
(
final
MapEntry
<
String
,
String
>
entry
in
env
.
entries
)
{
buffer
.
writeln
(
' "
${entry.key}
": "
${entry.value}
",'
);
}
buffer
.
writeln
(
'}'
);
}
buffer
.
write
(
_stringifyPubEnv
(
env
));
throw
io
.
ProcessException
(
exception
.
executable
,
exception
.
arguments
,
...
...
@@ -298,6 +291,20 @@ class _DefaultPub implements Pub {
);
}
// For surfacing pub env in crash reporting
String
_stringifyPubEnv
(
Map
<
String
,
String
>
map
,
{
String
prefix
=
'pub env'
})
{
if
(
map
.
isEmpty
)
{
return
''
;
}
final
StringBuffer
buffer
=
StringBuffer
();
buffer
.
writeln
(
'
$prefix
: {'
);
for
(
final
MapEntry
<
String
,
String
>
entry
in
map
.
entries
)
{
buffer
.
writeln
(
' "
${entry.key}
": "
${entry.value}
",'
);
}
buffer
.
writeln
(
'}'
);
return
buffer
.
toString
();
}
@override
Future
<
void
>
batch
(
List
<
String
>
arguments
,
{
...
...
@@ -330,13 +337,15 @@ class _DefaultPub implements Pub {
int
attempts
=
0
;
int
duration
=
1
;
int
code
;
final
List
<
String
>
pubCommand
=
_pubCommand
(
arguments
);
final
Map
<
String
,
String
>
pubEnvironment
=
await
_createPubEnvironment
(
context
,
flutterRootOverride
);
while
(
true
)
{
attempts
+=
1
;
code
=
await
_processUtils
.
stream
(
_pubCommand
(
arguments
)
,
pubCommand
,
workingDirectory:
directory
,
mapFunction:
filterWrapper
,
// may set versionSolvingFailed, lastPubMessage
environment:
await
_createPubEnvironment
(
context
,
flutterRootOverride
)
,
environment:
pubEnvironment
,
);
String
?
message
;
if
(
retry
)
{
...
...
@@ -372,7 +381,15 @@ class _DefaultPub implements Pub {
).
send
();
if
(
code
!=
0
)
{
throwToolExit
(
'
$failureMessage
(
$code
;
$lastPubMessage
)'
,
exitCode:
code
);
final
StringBuffer
buffer
=
StringBuffer
(
'
$failureMessage
\n
'
);
buffer
.
writeln
(
'command: "
${pubCommand.join(' ')}
"'
);
buffer
.
write
(
_stringifyPubEnv
(
pubEnvironment
));
buffer
.
writeln
(
'exit code:
$code
'
);
buffer
.
writeln
(
'last line of pub output: "
${lastPubMessage.trim()}
"'
);
throwToolExit
(
buffer
.
toString
(),
exitCode:
code
,
);
}
}
...
...
packages/flutter_tools/test/general.shard/dart/pub_get_test.dart
View file @
6abd3691
...
...
@@ -611,7 +611,7 @@ void main() {
);
});
expect
(
logger
.
errorText
,
isEmpty
);
expect
(
error
,
'test failed unexpectedly: Exception: pub get failed (69; no message)'
);
expect
(
error
,
contains
(
'test failed unexpectedly: Exception: pub get failed'
)
);
expect
(
processManager
,
hasNoRemainingExpectations
);
});
...
...
@@ -643,9 +643,19 @@ void main() {
botDetector:
const
BotDetectorAlwaysNo
(),
processManager:
processManager
,
);
const
String
toolExitMessage
=
'''
pub get failed
command: "bin/cache/dart-sdk/bin/dart __deprecated_pub --verbosity=warning get --no-precompile"
pub env: {
"FLUTTER_ROOT": "",
"PUB_ENVIRONMENT": "flutter_cli:flutter_tests",
}
exit code: 66
last line of pub output: "err3"
'''
;
await
expectLater
(
()
=>
pub
.
get
(
context:
PubContext
.
flutterTests
),
throwsA
(
isA
<
ToolExit
>().
having
((
ToolExit
error
)
=>
error
.
message
,
'message'
,
'pub get failed (66; err3)'
)),
throwsA
(
isA
<
ToolExit
>().
having
((
ToolExit
error
)
=>
error
.
message
,
'message'
,
toolExitMessage
)),
);
expect
(
logger
.
statusText
,
'Running "flutter pub get" in /...
\n
'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment