Repository navigation
fix: resolve path-valued Flutter build flags against the project (CLI-05) - #79
Merged
Merged
Conversation
Adds test/build_path_flags_test.rb, red on this commit: every path flag CLI-05 lists, as `--flag=value` and `--flag value` (and -o/-oVALUE), is resolved against the project root; absolute paths, values Ruflet cannot resolve and every other argument reach Flutter unchanged. The H1 flutter build stub now treats path options as Flutter does, relative to its working directory: --dart-define-from-file and --export-options-plist must exist, --split-debug-info, --code-size-directory (with --analyze-size), --performance-measurement-file and a web --output/-o directory are written there. Regenerated on this code, the goldens show today's behavior: inputs in the project are not found, and symbols and web output land inside build/client, so `ruflet build web -o dist` exports nothing. Six H1 invocations are added for the spellings not covered yet.
…-05) `ruflet build` runs Flutter in build/client, and Flutter resolves a relative path against its working directory. So `--dart-define-from-file=config/defines.json` and `--export-options-plist ExportOptions.plist` were not found, `--split-debug-info=symbols` wrote build/client/symbols, and `ruflet build web -o dist` wrote build/client/dist and exported nothing. The value of --dart-define-from-file, --split-debug-info, --export-options-plist, --code-size-directory, --performance-measurement-file and --output/--output-dir/-o is now made absolute against the project root before Flutter runs, in every spelling Flutter accepts (`--flag value`, `--flag=value`, `-o value`, `-ovalue`). Absolute paths, missing or empty values, values that look like a flag, an unexpanded `~`, and every other argument reach Flutter unchanged. H1: only the 9 goldens that pass one of these flags change (argv, and where the Flutter stub finds or writes the files).
This was referenced Nov 17, 2026
The review of the first fix found relative paths that work today and that it broke: paths written against build/client (`../../config/defines.json`, `../../ExportOptions.plist`, `../../symbols`, `-o ../web_dist`). Eight H1 invocations, generated with main's lib (today's behavior), pin those plus three more that must not move: `build web -o build/web` (the build exports it), `--split-debug-info=build/app/outputs/symbols` (exported with the APK) and `--split-debug-info=build/android/symbols` (today stranded in build/client; moved to ./build/android the export would delete it), and `--split-debug-info=symbols` into a RUFLET_CLIENT_DIR the developer owns. build_path_flags_test.rb now runs in a temporary project and covers each rule: inputs only when missing from the client dir and present in the project, outputs only from the managed build/client, the export guards, -o/--output only for web, and nothing after a bare `--`. The H1 flutter stub also stops at a bare `--` and, like Flutter, requires the export options plist to be a file.
…e is broken (CLI-05) The first fix rewrote every relative path against the project, which broke paths that work today (review of 1f3e2f9). A relative value now reaches Flutter as written unless the path Flutter would use, relative to the client dir, is broken: - inputs (--dart-define-from-file, --export-options-plist) are rewritten only when the value is not a file in the client dir, where Flutter would stop with "not found", and is one in the project; - outputs (--split-debug-info, --code-size-directory, --performance-measurement-file, and for web --output/--output-dir/-o) are rewritten only when they would land inside the managed build/client, which a template refresh deletes, outside what the build exports from there (build/client/build/<platform>), and when the project path is neither inside build/client nor inside the ./build/<platform> directory the export replaces. A client dir the developer owns (RUFLET_CLIENT_DIR, ./ruflet_client) keeps its outputs. -o/--output are handled only for web, the one Ruflet target Flutter gives them, and nothing after a bare `--` is touched. So `../../symbols`, `-o ../web_dist`, `-o build/web` and the other spellings that work today are unchanged, and the eight goldens of the previous commit pass.
… root as written, and resolve ipa like ios (CLI-05) An output whose project path is outside the project, is the project root, or is a directory holding build/client (./build) is left as written. The resolver maps ipa to ios itself instead of relying on its caller. Unit tests pin these, a directory standing in for an input, and outputs beside the export directories.
…lings (CLI-05) Flutter refuses --analyze-size for an apk built for its three default ABIs (android/build_validation.dart), so the corpus entry now passes --target-platform android-arm64 and the flutter stub models the check. New goldens, generated with main's lib: build ipa --split-debug-info=build/ios/symbols, build apk --split-debug-info=../client/symbols, build web -o . and -o build.
AdamMusa
added a commit
that referenced
this pull request
Nov 20, 2026
…t Ruby cannot read On a file system that ignores case (APFS and NTFS by default), the resolver compared paths by string, so it rewrote outputs that work today: `build web -o Build/Web` and `--split-debug-info=Build/App/Outputs/...` are exported from build/client, and `-o BUILD` is ./build. The comparisons now fold case where the file system holding the client dir does. H1 goldens generated with main's lib pin five such spellings. An argument or value that is not valid in its encoding, or whose encoding clashes with the project path, now reaches Flutter as written instead of raising ArgumentError in the resolver, as on main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WP-00 CLI-05. Based on
main, which is merged in with merge commits:08207d86brings in27e2ffa8(#78),f8291c17brings inea3f7eb0(#98),a1bd686abrings inf034e99b(#109),2f133ebebrings in06c6e28f(#84) ande3bf262bbrings in33705440(#89). This PR's own commits are6c79d407,1f3e2f9d,0c3e47f0,64ca3df2,d3edbd79,780c31a8,7c135090and43515045.What
ruflet buildrunsflutter buildwithchdir:set to the client dir (build_command.rb:201). Flutter resolves a relative path against its working directory. A path the developer meant relative to the project is therefore read from, or written to,build/client.This PR makes a relative value of a path-valued flag absolute against the project root, but only when the path Flutter would use today is broken. Every other value reaches Flutter exactly as written.
--dart-define-from-file,--export-options-plist) are rewritten only when the value is not a file relative to the client dir (Flutter would stop with "not found") and is a file relative to the project.--split-debug-info,--code-size-directory,--performance-measurement-file, and forbuild webalso--output,--output-dirand-o) are rewritten only when all of these hold:build/client, which a template refresh deletes (client_dir.rb:47,new_command.rb:77);build/client;build/client/build/<web|ios|macos|windows|linux|app/outputs>);./build, which holdbuild/client;build/client;./build/<platform>directory that the export deletes and replaces (exports.rb:24).build/clientignores case (the APFS and NTFS default), these comparisons ignore case too. The check isFile.identical?(build/client, build/CLIENT). On such a file system,-o Build/Webis the exportedbuild/client/build/weband-o BUILDis./build, so both stay as written.An
ipais resolved likeios. The resolver does this mapping itself, so it does not depend on its caller.Left as written:
build/client, such as../../symbols;RUFLET_CLIENT_DIR,./ruflet_client);~that no shell expanded;--dart-define=GREETING=caf\xE9in a UTF-8 locale), or whose encoding clashes with the project path's.mainforwards these untouched. Ona1bd686a, the first raisedArgumentErrorand the second raisedEncoding::CompatibilityError;-o/--outputfor targets other than web, because Flutter gives them no such option;--.The resolver handles every spelling Flutter's parser accepts:
--f v,--f=v,-o vand-ov.Why
CLI-05 (P1). An earlier head (
1f3e2f9d) rewrote every relative path, and that broke spellings that work today.a1bd686astill compared paths case-sensitively. On APFS it rewrote-o Build/Weband--split-debug-info=Build/App/Outputs/symbols, whichmainexports. This head keeps all of them working, and H1 goldens and unit tests pin them.Behavior changes
The table lists exactly the 9 H1 goldens that differ from
main. Each of these invocations is broken onmain: either Flutter exits 1, or the output is stranded inbuild/clientand deleted at the next template refresh.mainbuild apk --self --dart-define-from-file=config/defines.json(also--dart-define-from-file config/defines.json)<project>/config/defines.jsonis read, exit 0build ipa --self --export-options-plist ExportOptions.plist<project>/ExportOptions.plistis read, exit 0build apk --self --split-debug-info=symbols [--obfuscate](also--split-debug-info symbols)build/client/symbols./symbolsbuild apk --self --analyze-size --target-platform android-arm64 --code-size-directory=sizes --performance-measurement-file perf.jsonbuild/client/sizes,build/client/perf.json./sizes,./perf.jsonbuild web -o dist(also--output dist,--output-dir=dist)build/client/dist, not exported./dist[ruflet build] Running Flutter …line shows the rewritten values as absolute paths.-o Build/Webnames a directory that is neither exported nor./build. There it falls under the last row:mainstrands it inbuild/client/Build/Web, and this PR writes./Build/Web.--analyze-sizefor an apk built for its three default ABIs (android/build_validation.dart:14), both onmainand with this PR. That is why the size-analysis row names one--target-platform. The H1 flutter stub models that check.git grepon ruflet_siteorigin/main4d02964).Unchanged (H1 goldens generated with
main's lib)build apk --self --dart-define-from-file=../../config/defines.jsonbuild ipa --self --export-options-plist ../../ExportOptions.plistbuild apk --self --split-debug-info=../../symbolsbuild apk --self --split-debug-info=../client/symbols: this isbuild/client/symbolstoday. Rewritten, it would land outside the project.build web -o ../web_distbuild web -o .andbuild web -o build: insidebuild/clienttoday. Rewritten, they would land on the project root and on./build.build web -o build/web(exported)build apk --self --split-debug-info=build/app/outputs/symbols(exported with the APK)build apk --self --split-debug-info=build/android/symbols: rewritten, the export would delete it.build ipa --self --split-debug-info=build/ios/symbols(exported withbuild/ios)RUFLET_CLIENT_DIR=<client> build apk --self --split-debug-info=symbols: written into that client, as today.build web -o Build/Web: exported to./build/web.build web -o BUILD:./build.build web -o Build/Client/web_out: insidebuild/client.build apk --self --split-debug-info=Build/App/Outputs/symbols: exported to./build/android/symbols.build apk --self --split-debug-info=Build/Android/symbols: the export would replace it.Tests (head
43515045; merged heade3bf262bat the end)All runs used Homebrew Ruby 4.0.5 with
GEM_HOMEunset, unless noted otherwise.ruby test/compat/compat.rb --jobs 4checked 343 goldens with 0 failing. It also passes on rbenv Ruby 3.4.5.main: running this head'stest/compatwithmain's lib (06c6e28f) gives "343 goldens, 9 failing". The 9 are exactly the goldens in the table. All 17 "Unchanged" goldens pass.a1bd686a'sflutter_tooling.rb, all 5 new case goldens fail ("8 goldens, 5 failing").test/build_path_flags_test.rb(28 tests) runs in a temporary project and covers every rule above. The case rules are tested both ways (case ignored and case significant), and also as this machine's file system behaves.File.exist?in place ofFile.identical?in the case check, on a host that ignores case.packages/ruflettest file passes when run in its own process: 26 files, 826 runs, 0 failures, 0 errors. That includescompat_goldens_test.rb(351 runs). No other package changes.43515045: every job passed (publish is skipped). "Verify Ruflet Explorer" runs on Ruby 3.4.5; its "Run framework tests" step ranbuild_path_flags_test(28 runs) andcompat_goldens_test(351 runs, with 1 railties skip thatmainhas too).e3bf262b(origin/main33705440merged in; that merge changes onlypackages/ruflet_serverand.github/workflows/build-ruflet-client.yml, andgit diff origin/main e3bf262bequals this PR's diff before the merge): H1 checked 343 goldens with 0 failing; everypackages/ruflettest file in its own process: 26 files, 826 runs, 0 failures; all 17packages/ruflet_servertest files pass.Not in this PR
ruflet.yamlkey for these paths (BD-05/BD-10).cli_reference.md/build_and_release.md: what a relative path in a forwarded flag means). These go in a follow-up docs PR.packages/ruflet/libgrows from 378,869 to 386,478 bytes against06c6e28f. There is no native, Flutter or template change.