Repository navigation
fix: use the Flutter SDK Ruflet installed under ~/.ruflet/flutter without the network or --fix - #111
Merged
Merged
Conversation
flutter_tools_via_managed_sdk returned nil whenever auto_install was off, so plain `ruflet doctor` never looked at ~/.ruflet/flutter and reported "Flutter: missing" right after `ruflet doctor --fix` installed an SDK there. ensure_flutter_sdk_downloaded fetched the release manifest before checking the disk, so offline every command failed with "Flutter auto-install failed" while the SDK was installed. installed_managed_flutter_sdk_root finds an SDK that an earlier run put in ~/.ruflet/flutter/<version>/<host>/flutter. It is used without auto-install, and when the release manifest can't be fetched or returns nothing. An explicit version pin (RUFLET_FLUTTER_VERSION, .fvmrc) accepts only that exact version. Otherwise the newest installed stable SDK is used. Online with auto-install, nothing changes: the manifest still picks the release and downloads it when it is missing. Fixes #110
…d ordering cases The guards for the release manifest and download_file raised NoMethodError (flunk on the dummy) or RuntimeError, both StandardErrors that the offline rescue in ensure_flutter_sdk_downloaded swallows. They now raise Minitest::Assertion, so plain doctor fetching the manifest fails the tests. Add tests for an x.y.z@channel pin, a beta channel preferring the newest -pre SDK, and a newest-stable fixture where string or directory order would pick a different SDK.
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.
Fixes #110
What changed
packages/ruflet/lib/ruflet/cli/flutter_sdk.rb:installed_managed_flutter_sdk_root. It finds an SDK that an earlier run ofensure_flutter_sdk_downloadedinstalled, at~/.ruflet/flutter/<version>/<host>/flutter, and accepts only an executablebin/flutterfor the current host.x.y.zversion pin (RUFLET_FLUTTER_VERSIONor.fvmrc, e.g.3.41.2or3.41.2@stable) accepts only that exact version. It never swaps in a different installed SDK..metadata, the default, a channel name such asstable, or a partial version such as3.41), the newest installed SDK is used. Unless the template.metadatanames another channel, stable releases rank above-preones, so a-preSDK is used only when no stable one is installed. This matches the online lookup, which only uses a channel from.metadata.flutter_tools_via_managed_sdkwithauto_install: false(plainruflet doctor) now uses that installed SDK instead of returning nil. It still downloads nothing and makes no network request.ensure_flutter_sdk_downloadedfalls back to the installed SDK whenresolve_flutter_releaseraises (offline) or returns nil (non-200 manifest, or no matching release). If nothing suitable is installed, the old behavior is kept: the sameFlutter auto-install failed: ...warning and nil.Online with auto-install, nothing changes. The manifest still picks the release, the "already installed" check still comes after it, and a release that is not installed is still downloaded. A Flutter on
PATHand FVM SDKs are resolved exactly as before, and they still win over the managed SDK.No app code,
ruflet.yamlkey or command-line invocation changes.Behavior changes
Each item below was broken before and is listed here as a bug fix (D6):
Plain
ruflet doctorwith no system or FVM Flutter, and an SDK under~/.ruflet/flutter. Before, it printedFlutter: missingand the "Runruflet doctor --fix" hint and exited 1. That happened right afterdoctor --fixhad installed the SDK. Now it printsFlutter: <version> <channel>, runsflutter doctorwith that SDK and returns its status, the same waydoctor --fixdoes. Plain doctor still makes no network request, so it reports the newest installed SDK and does not check whether a newer stable release exists. A later onlinebuildmay still download a newer release, as it did before.Commands that need Flutter when the release manifest can't be fetched, with a suitable SDK installed under
~/.ruflet/flutter. This coversbuild,install,debug,devices,emulators,updateanddoctor --fix, when offline or when the manifest returns a non-200 response. Before, they printedFlutter auto-install failed: <error>andFlutter is required for ...and exited 1. Now they use the installed SDK. With a concretex.y.zpin they only do so when that exact version is installed; otherwise they fail exactly as before. A partial pin such as3.41uses the newest installed SDK, the same way the online manifest lookup warns and takes the latest stable for it.A side effect of the same fallback: for a pinned project offline, with no
fvmordartonPATH,ensure_fvm_availablenow gets the installed SDK'sdartand triesdart pub global activate fvm(output discarded), exactly as it does online. Before, it got nil. If~/.pub-cache/bin/fvmalready exists from an earlier activation, the CLI then also writes.fvmrc(when there is none) into the FVM project dir (the build client dir, the directory of a.fvmrcin the current dir, or~/.ruflet/fvm_project) and runsfvm install <pin>andfvm use --force <pin>there, as it does online. Before, this case called nothing and exited 1.No other output changes. The H1 goldens use a Flutter on
PATHand are unchanged.How it was verified
All on the final head, which includes merges of current
main(2801ae4). Those merges touch none of the three files this PR changes, and the PR diff againstmainis unchanged.test/flutter_sdk_test.rband 1 intest/extra_command_test.rb. In each test, the release manifest fetch anddownload_filefail the test if they are called, unless the test replaces them. The guards raiseMinitest::Assertion, which is not aStandardError, so the offlinerescue StandardErrorcannot swallow them.flutter_tools(auto_install: false)finds the installed SDK.Errno::ECONNREFUSED) and nil-manifest cases fall back to the installed SDK without the failure warning.Flutter auto-install failed: Errno::ECONNREFUSEDand returns nil.3.41.2@stablematches3.41.2, and a pin that is not installed is never replaced.-preversions rank below stable. With a.metadatachannel ofbeta, the newest-preSDK wins.command_doctor([]): with an SDK under a temporaryHOMEand no Flutter onPATH, it exits 0, printsFlutter: 3.41.2 stableand runsflutter doctorwith that SDK.main'sflutter_sdk.rband the new tests, 9 tests fail: 4 behavior tests, and 5 helper tests that fail withNoMethodError. The 3 guard tests (online download, offline with nothing installed, nothing created) pass on both versions, which shows those paths are unchanged.flutter_sdk.rball fail at least one test. One makes plain doctor callensure_flutter_sdk_downloaded, so it fetches the manifest; it fails 2 tests influtter_sdk_test.rband 1 inextra_command_test.rb.flutter,fvmordartis onPATH. A temporaryHOMEholds the managed SDK and the real template.metadata, and only the manifest fetch is stubbed. Run on this branch and onmain, 14 cases:doctoronline (0 manifest fetches) and offline goes from exit 1 to exit 0; offlinedevicesandemulators, offlinedeviceswith an installed pin fromRUFLET_FLUTTER_VERSIONor.fvmrc, anddeviceswith a non-200 manifest go from exit 1 to exit 0.main: onlinedoctor --fixanddevices(1 manifest fetch each, no download), offlinedevicesanddoctorwith a pin that is not installed, onlinedeviceswith3.41.2@stable, and an unreadable~/.ruflet/flutter.packages/rufletsuites. All 22 test files pass, each in its own process, on Ruby 4.0.5, includingcompat_goldens_test.rbwith 322 runs.flutter_sdk_test.rbandextra_command_test.rbalso pass with seeds 1, 7, 99 and 4242. CI on this head ran the framework tests on.ruby-version3.4.5, and they pass:flutter_sdk_test.rbwith 22 runs andextra_command_test.rbwith 3 runs.cd packages/ruflet && ruby test/compat/compat.rb --jobs 4checked 314 goldens, all passing.git merge-treeof this head with each open PR shows no conflict in the files this PR changes. Only feat: warn when the template lacks a control, service or extension the app uses (CRIT-04b) #80 and CLI: cover every command and option, fix what the tests exposed #84 conflict, and each conflicts in exactly the same files when merged withmain.