[Linux] Set Platform.executable on startup
Note: this is WIP. Pushing so I don't forget to pick this up on Monday.
When setting FlutterProjectArgs.command_line_argv prior to launching the
engine, we were previously setting a placeholder value rather than the
executable name. This resulted in Platform.executable (from dart:io)
returning "placeholder" in application code.
This updates the Linux implementation for consistency with macOS and Windows and guarantees that Platform.executable will return a reasonable value in Dart code.
Note that this does not affect Platform.resolvedExecutable, which returns
a full, resolved path, and is implemented in the Dart runtime itself.
Previously the code:
print(Platform.executable);
print(Platform.resolvedExecutable);
resulted in the following output on Windows:
flutter: flutter
flutter: /path/to/project/build/linux/runner/Debug/project
after this patch, it results in:
flutter: project
flutter: /path/to/project/build/linux/runner/Debug/project
Issue: https://github.com/flutter/flutter/issues/83921
Pre-launch Checklist
- [ ] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [ ] I read the Tree Hygiene wiki page, which explains my responsibilities.
- [ ] I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
- [ ] I listed at least one issue that this PR fixes in the description above.
- [ ] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
- [ ] I updated/added relevant documentation (doc comments with
///). - [ ] I signed the CLA.
- [ ] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel on Discord.
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).
If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?
Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.
Are we still working on this?
Yeah; this is an easy fix but testing it requires me to land fixture test support for linux, which shouldn't be too hard to do. I'll see if I can get round to it in the next few weeks.
Closing this as stale. Please re-open once progress can be made.