Skip to content

CLI: the Flutter SDK Ruflet installs under ~/.ruflet/flutter is invisible to plain ruflet doctor, and every command needs the network to find it #110

Closed

Description

@AdamMusa

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:

  1. Plain ruflet doctor (without --fix) still says Flutter: missing and exits 1, and tells you to run ruflet doctor --fix, which you just did. Running both commands in a row loops.
  2. 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 with Flutter 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 --fix installs the SDK, plain ruflet doctor reports it. docs/cli_reference.md says 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_fvm checks existing_fvm_flutter_bin before return nil unless auto_install.

Cause

packages/ruflet/lib/ruflet/cli/flutter_sdk.rb:

  • flutter_tools_via_managed_sdk starts with return nil unless auto_install (line 77). command_doctor without --fix calls flutter_tools(auto_install: false) (extra_command.rb:44), so it never looks at disk.
  • ensure_flutter_sdk_downloaded calls resolve_flutter_release at line 169. That call fetches releases_<host>.json over the network, before the "already installed" check at line 178. A network error lands in the method's rescue, which prints Flutter auto-install failed and 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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions