Repository navigation
Description
Summary
When there is no Flutter on PATH and no FVM, Ruflet installs a Flutter SDK itself under ~/.ruflet/flutter/<version>/<host>/flutter (ruflet doctor --fix, or the first build/devices/...). After that:
- Plain
ruflet doctor(without--fix) still says Flutter: missing and exits 1, and tells you to runruflet doctor --fix, which you just did. Running both commands in a row loops. - Every command that needs Flutter (
build,install,debug,devices,emulators,update,doctor --fix) first downloads the Flutter release manifest before it looks at the installed SDK. Offline, or when the manifest can't be fetched, those commands fail withFlutter auto-install failed: ...and exit 1, even though the SDK is on disk.
This only affects zero-setup users, the ones who rely on Ruflet to manage Flutter. A Flutter on PATH or an FVM SDK is not affected. The bug is on main and in the published 0.0.23 gem, where flutter_sdk.rb and extra_command.rb are byte-identical.
Repro
Use a temporary HOME and a PATH with no flutter, fvm or dart. Put an executable flutter stub at ~/.ruflet/flutter/3.41.2/macos_arm64/flutter/bin/flutter, the path ensure_flutter_sdk_downloaded installs to. The stub answers --version --machine with {"frameworkVersion":"3.41.2","channel":"stable"}. Add a current template cache. Stub only the network boundary (fetch_releases_manifest). To go offline, point https_proxy at a closed port.
### online: ruflet doctor --fix
Flutter: 3.41.2 stable
exit=0
### online: ruflet doctor (right after --fix)
Flutter: missing
Run `ruflet doctor --fix` to install the host-platform Flutter SDK from .fvmrc.
exit=1
### offline: ruflet doctor
Flutter: missing
exit=1
### offline: ruflet devices
Flutter auto-install failed: Errno::ECONNREFUSED: Failed to open TCP connection to 127.0.0.1:9 (Connection refused ...)
Flutter is required for `ruflet devices` and FVM bootstrap failed.
exit=1
### offline: ruflet emulators
Flutter auto-install failed: Errno::ECONNREFUSED: ...
exit=1
The results are the same when the cache holds the real template .metadata, so that the desired spec comes from :metadata as it does for real users. With download_file stubbed to raise, nothing is downloaded in any of the runs.
Expected
- After
--fixinstalls the SDK, plainruflet doctorreports it.docs/cli_reference.mdsays doctor reports Flutter. - An SDK that is already on disk can be used without downloading the release manifest first. The FVM path already does this:
flutter_tools_via_fvmchecksexisting_fvm_flutter_binbeforereturn nil unless auto_install.
Cause
packages/ruflet/lib/ruflet/cli/flutter_sdk.rb:
flutter_tools_via_managed_sdkstarts withreturn nil unless auto_install(line 77).command_doctorwithout--fixcallsflutter_tools(auto_install: false)(extra_command.rb:44), so it never looks at disk.ensure_flutter_sdk_downloadedcallsresolve_flutter_releaseat line 169. That call fetchesreleases_<host>.jsonover the network, before the "already installed" check at line 178. A network error lands in the method'srescue, which printsFlutter auto-install failedand returns nil. A non-200 manifest returns nil without printing anything.
The guard came in with e5e162c ("Automate Ruflet first-run build setup") because ensure_flutter_sdk_downloaded both resolves and downloads. The only related test, test_doctor_without_fix_reports_missing_flutter_without_installing, checks that nothing is installed. It does not check that an installed SDK is ignored.
Activity