Repository navigation
flutter devices --machine prints upgrade banner breaking machine parsing #145158
Copy link
Copy link
Closed
Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Description
Running 'et run' failed with the following error. When flutter is invoked with --machine we shouldn't print out the human upgrade banner.
[2024-03-14 09:06:20.309447] ERROR: Failed to parse flutter devices output: FormatException: Unexpected character (at line 2, character 1)
┌─────────────────────────────────────────────────────────┐
^
┌─────────────────────────────────────────────────────────┐
│ A new version of Flutter is available! │
│ │
│ To update to the latest version, run "flutter upgrade". │
└─────────────────────────────────────────────────────────┘
[
{
"name": "sdk gphone64 arm64",
"id": "emulator-5554",
"isSupported": true,
"targetPlatform": "android-arm64",
"emulator": true,
"sdk": "Android 14 (API 34)",
"capabilities": {
"hotReload": true,
"hotRestart": true,
"screenshot": true,
"fastStart": true,
"flutterExit": true,
"hardwareRendering": true,
"startPaused": true
}
},
{
"name": "macOS",
"id": "macos",
"isSupported": true,
"targetPlatform": "darwin",
"emulator": false,
"sdk": "macOS 14.4 23E214 darwin-arm64",
"capabilities": {
"hotReload": true,
"hotRestart": true,
"screenshot": false,
"fastStart": false,
"flutterExit": true,
"hardwareRendering": false,
"startPaused": true
}
},
{
"name": "Mac Designed for iPad",
"id": "mac-designed-for-ipad",
"isSupported": true,
"targetPlatform": "darwin",
"emulator": false,
"sdk": "macOS 14.4 23E214 darwin-arm64",
"capabilities": {
"hotReload": true,
"hotRestart": true,
"screenshot": false,
"fastStart": false,
"flutterExit": true,
"hardwareRendering": false,
"startPaused": true
}
},
{
"name": "Chrome",
"id": "chrome",
"isSupported": true,
"targetPlatform": "web-javascript",
"emulator": false,
"sdk": "Google Chrome 123.0.6312.46",
"capabilities": {
"hotReload": true,
"hotRestart": true,
"screenshot": false,
"fastStart": false,
"flutterExit": false,
"hardwareRendering": false,
"startPaused": true
}
}
]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Activity
zanderso commentedon Mar 14, 2024
@christopherfujino Does the tool have a flag to suppress the upgrade check?
christopherfujino commentedon Mar 14, 2024
Hmm, looks like the intention is to skip the check if we're in machine mode: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart#L326
Must be a bug.
bartekpacia commentedon Mar 15, 2024
I worked around this in a CLI tool I wrote by running
flutter --no-version-check devices --machine. But yeah, would be great if it was fixed.zanderso commentedon May 17, 2024
zanderso commentedon May 17, 2024
The tool defines the
--machineflag twice =(There's a top-level flag, which is what is checked by:
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart#L326
Then the
devicescommand defines its own version of the flag:https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/commands/devices.dart#L17
The logic that decides to skip the version check in the presence of the
--machineflag is looking for the flag at thetop-level, and isn't aware if/when the--machineflag is passed to thedevicescommand.Ideally, instead of defining its own
--machineflag, thedevicescommand should just look for the top-level flag. Unfortunately, that would be a breaking change since it would change the location on the command line where the--machineflag goes. To do a soft breaking change, as an intermediate step, the logic influtter_command_runner.dartshould look to see if--machinehas been passed anywhere on the command line, and not just as a top-level flag.matanlurey commentedon May 17, 2024
I thought
package: argswas relaxed about flag location, I need to double check.I can volunteer in either case to get the bug fixed at the tools level.
matanlurey commentedon May 17, 2024
I paired with @jonahwilliams for a few minutes, and I'm out of 🧠 power to fix this today, but tl;dr there are multiple different commands that support
--machinetoday, so it's likely non-viable (without a much bigger undertaking) to deprecate and refactor down. I can file a bug, but can't commit to fixing itTo fix this specific problem we'd modify the check for machine to, as @zanderso mentioned, look for
--machinebeing present anywhere in the command-line arguments, not just the root command.johnmccutchan commentedon May 21, 2024
Would running the following work:
flutter --machine devices --machine?
Suppress Flutter update check if `--machine` is present at all. (#150138
Suppress Flutter update check if `--machine` is present at all. (flut…
Suppress Flutter update check if `--machine` is present at all. (flut…
github-actions commentedon Jun 27, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.