Repository navigation
Fix relative executable execution under posix_spawn - #193595
Conversation
733c15f to
9a8f8bf
Compare
9a8f8bf to
2e59ab2
Compare
2e59ab2 to
14fd92c
Compare
f2a051a to
3cd04f0
Compare
3cd04f0 to
f8c1ea6
Compare
f8c1ea6 to
a1ca434
Compare
There was a problem hiding this comment.
Code Review
This pull request refactors several test runners, scripts, and utility files to dynamically resolve executable and script paths using the path package instead of hardcoding relative paths. This improves cross-platform compatibility, particularly on Windows. Feedback on these changes suggests using androidDirectory.absolute when resolving the gradlew path in gradle_utils.dart to guarantee an absolute path and prevent potential working directory discrepancies.
| // print the kgp version if gradle can run successfully. | ||
|
|
||
| if (processManager.canRun('./gradlew', workingDirectory: androidDirectory.path)) { | ||
| final String gradlew = androidDirectory.childFile(getGradlewFileName(platform)).path; |
There was a problem hiding this comment.
To ensure the resolved gradlew path is always absolute and fully immune to any working directory discrepancies under posix_spawn (even if androidDirectory is instantiated as a relative path), consider using androidDirectory.absolute.
| final String gradlew = androidDirectory.childFile(getGradlewFileName(platform)).path; | |
| final String gradlew = androidDirectory.absolute.childFile(getGradlewFileName(platform)).path; |
There was a problem hiding this comment.
I tried this and it broke a bunch of stuff in project_test.dart. Also, in production FlutterProject.current(), androidDirectory is derived from globals.fs.currentDirectory, so it is already unconditionally absolute
| if (io.Platform.isWindows) { | ||
| executable = 'powershell'; | ||
| args = <String>[path.join('bin', 'internal', 'content_aware_hash.ps1')]; | ||
| args = <String>['-File', path.join(scriptDir, 'content_aware_hash.ps1')]; |
There was a problem hiding this comment.
this one had to be a fun one to debug.
|
Detected the If you add the The "Merge" button is also unlocked. To bypass presubmits as well as the tree status, press the GitHub "Add to Merge Queue". |
|
auto label is removed for flutter/flutter/193595, Failed to enqueue flutter/flutter/193595 with HTTP 400: Pull request Required status check "Google testing" is in progress.. |
|
flutter / Mac mac_unopt flaked. It passed on the previous commit and the only change since then was a comment change. I hit the merge now button |

Related to #193579
Follow-up to #193582 and #193664
Dart SDK commit 0171629a5478 migrated macOS process spawning to
posix_spawn. Underposix_spawnand WindowsCreateProcess,Process.startresolves relative executables against the caller's working directory rather than the targetworkingDirectory.While PR #193582 and PR #193664 addressed
customer_testing, other areas across the repository still invoke relative executables with custom working directories directly viaProcess.start/Process.run. This PR addresses the remaining locations:dev/bots/suite_runners: Construct absolute script paths inrun_add_to_app_life_cycle_tests.dart,run_docs_tests.dart, andrun_skp_generator_tests.dart.packages/flutter_tools: Ingradle_utils.dart, resolvegradlew/gradlew.batviaandroidDirectory.childFile(...).dev/devicelab: Inutils.dartstartProcess, normalize relative executables containing directory separators againstfinalWorkingDirectory.content_aware_hashinweb_ui/dev/common.dartandgradlewintools/gradle/generate_gradle_cipd_packages.dart.Testing
flutter_tools: Unit tests inpackages/flutter_tools/test/general.shard/android/gradle_utils_test.dartandproject_test.dartcover POSIX and Windowsgradlewpath resolution.dev/,engine/): Validated via CI runs (test-exempt: changes to test infrastructure).Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.