Skip to content

Fix relative executable execution under posix_spawn - #193595

Merged
andywolff merged 2 commits into
flutter:masterfrom
andywolff:dart_roller_fix
Oct 2, 2026
Merged

andywolff merged 2 commits into
flutter:masterfrom
andywolff:dart_roller_fix

Conversation

@andywolff

@andywolff andywolff commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Related to #193579
Follow-up to #193582 and #193664

Dart SDK commit 0171629a5478 migrated macOS process spawning to posix_spawn. Under posix_spawn and Windows CreateProcess, Process.start resolves relative executables against the caller's working directory rather than the target workingDirectory.

While PR #193582 and PR #193664 addressed customer_testing, other areas across the repository still invoke relative executables with custom working directories directly via Process.start / Process.run. This PR addresses the remaining locations:

  1. dev/bots/suite_runners: Construct absolute script paths in run_add_to_app_life_cycle_tests.dart, run_docs_tests.dart, and run_skp_generator_tests.dart.
  2. packages/flutter_tools: In gradle_utils.dart, resolve gradlew / gradlew.bat via androidDirectory.childFile(...).
  3. dev/devicelab: In utils.dart startProcess, normalize relative executables containing directory separators against finalWorkingDirectory.
  4. Engine tooling: Resolve absolute paths for content_aware_hash in web_ui/dev/common.dart and gradlew in tools/gradle/generate_gradle_cipd_packages.dart.

Testing

  • flutter_tools: Unit tests in packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart and project_test.dart cover POSIX and Windows gradlew path resolution.
  • Test infrastructure (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-assist bot 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.

@andywolff andywolff added the CICD Run CI/CD label Sep 30, 2026
@andywolff
andywolff force-pushed the dart_roller_fix branch 2 times, most recently from 733c15f to 9a8f8bf Compare October 1, 2026 16:42
@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-android Owned by Android platform team team-web Owned by Web platform team labels Oct 1, 2026
@andywolff andywolff removed the CICD Run CI/CD label Oct 1, 2026
@andywolff andywolff changed the title Remove relative executable script paths from test suite runners Fix relative executable execution under posix_spawn Oct 1, 2026
@andywolff andywolff added the CICD Run CI/CD label Oct 1, 2026
@andywolff
andywolff force-pushed the dart_roller_fix branch 2 times, most recently from f2a051a to 3cd04f0 Compare October 1, 2026 22:41
@andywolff
andywolff marked this pull request as ready for review October 2, 2026 07:21
@andywolff
andywolff requested a review from a team as a code owner October 2, 2026 07:21
@andywolff
andywolff requested review from reidbaker and removed request for a team October 2, 2026 07:21

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
final String gradlew = androidDirectory.childFile(getGradlewFileName(platform)).path;
final String gradlew = androidDirectory.absolute.childFile(getGradlewFileName(platform)).path;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread dev/devicelab/lib/framework/utils.dart
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')];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one had to be a fun one to debug.

jtmcdole
jtmcdole previously approved these changes Oct 2, 2026

@jtmcdole jtmcdole left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪙 The CodeFu LGTM Coin: Hard currency for soft commits.

  • Value: Pegged directly to 100 perfectly formatted Dart lines.
  • Utility: Redeemable for an emergency CI queue-jump or bypassing a non-blocking linter warning.
  • ⚠️ Warning: Subject to sudden hyperinflation if the engine roll breaks main.

codefu-coin

@andywolff andywolff added autosubmit Merge PR when tree becomes green via auto submit App emergency Jump the queue; land PR in front of all others; only use for emergencies labels Oct 2, 2026
@flutter-dashboard

Copy link
Copy Markdown

Detected the emergency label.

If you add the autosubmit label, the bot will wait until all presubmits pass but ignore the tree status, allowing fixes for tree breakages while still validating that they don't break any existing presubmits.

The "Merge" button is also unlocked. To bypass presubmits as well as the tree status, press the GitHub "Add to Merge Queue".

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 2, 2026
@auto-submit

auto-submit Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

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..

@andywolff
andywolff added this pull request to the merge queue Oct 2, 2026
@andywolff

Copy link
Copy Markdown
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD emergency Jump the queue; land PR in front of all others; only use for emergencies engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-android Owned by Android platform team team-web Owned by Web platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants