-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Description
Repro
- Create a flutter project.
- Navigate to the project directory.
- Create a file named
config.json
with the content:{ "MY_ENV_VALUE": "json \n foo \n" }
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