Content-Length: 275560 | pFad | https://github.com/flutter/flutter/issues/129608

AC [flutter_tools] --dart-defines-json option of `flutter run` results in failed compilation if json values contain newline characters · Issue #129608 · flutter/flutter · GitHub
Skip to content

[flutter_tools] --dart-defines-json option of flutter run results in failed compilation if json values contain newline characters #129608

@andrewkolos

Description

@andrewkolos

Repro

  1. Create a flutter project.
  2. Navigate to the project directory.
  3. Create a file named config.json with the content:
    {
      "MY_ENV_VALUE": "json \n foo \n"
    }
  4. flutter run -d chrome --dart-define-from-file=config.json (you don't have to use chrome as the device)

The command fails with output resembling

Launching lib/main.dart on Chrome in debug mode...
-DMY_ENV_VALUE=json%20%0A%20foo%20%0A: Error: Error when reading '-DMY_ENV_VALUE=json%20%0A%20foo%20%0A': No such file or directory
Waiting for connection from debug service on Chrome...             487ms
Failed to compile application.

Troubleshooting

From the error message, it appears dart is trying to compile -DMY_ENV_VALUE=... rather than the actual dart file (lib/main.dart). It's possible that the newline is ending the command input early, before the actual dart file is provided, so the -D (--define) option is being falsely interpreted as the file to compile.

Where we invoke the dart command.

Solution

It might not be possible for us to support new lines in these config values. I am not sure if Process.start from dart.io (which is what we ultimately call) is able to support multiline command arguments.

If it's not possible for us to fix this issue directly, we should at least detect config values containing newlines and throw a ToolExit telling the user that we do not support values with newlines in them.

Tangentially related: #128787

Metadata

Metadata

Assignees

No one assigned

    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.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/flutter/flutter/issues/129608

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy