Skip to content

flutter devices --machine prints upgrade banner breaking machine parsing #145158

Closed

Description

@johnmccutchan

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
    }
  }
]

Activity

  1. zanderso commented on Mar 14, 2024

    @zanderso
    Member

    @christopherfujino Does the tool have a flag to suppress the upgrade check?

  2. christopherfujino commented on Mar 14, 2024

    @christopherfujino
    Contributor

    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.

  3. bartekpacia commented on Mar 15, 2024

    @bartekpacia
    Member

    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.

  4. zanderso commented on May 17, 2024

    @zanderso
  5. zanderso commented on May 17, 2024

    @zanderso
    Member

    The tool defines the --machine flag 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 devices command 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 --machine flag is looking for the flag at the top-level, and isn't aware if/when the --machine flag is passed to the devices command.

    Ideally, instead of defining its own --machine flag, the devices command 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 --machine flag goes. To do a soft breaking change, as an intermediate step, the logic in flutter_command_runner.dart should look to see if --machine has been passed anywhere on the command line, and not just as a top-level flag.

  6. matanlurey commented on May 17, 2024

    @matanlurey
    Contributor

    I thought package: args was relaxed about flag location, I need to double check.

    I can volunteer in either case to get the bug fixed at the tools level.

  7. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    P2Important issues not at the top of the work list
    team-toolOwned by Flutter Tool team
    on May 17, 2024
  8. matanlurey commented on May 17, 2024

    @matanlurey
    Contributor

    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 --machine today, 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 it

    To fix this specific problem we'd modify the check for machine to, as @zanderso mentioned, look for --machine being present anywhere in the command-line arguments, not just the root command.

  9. johnmccutchan commented on May 21, 2024

    @johnmccutchan
    ContributorAuthor

    Would running the following work:

    flutter --machine devices --machine

    ?

  10. github-actions commented on Jun 27, 2024

    @github-actions

    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 -v and a minimal reproduction of the issue.

  11. locked as resolved and limited conversation to collaborators on Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions