Skip to content

flutter update-packages --offline does not pass --offline to pub #193423

Closed

Description

@jwinarske

The flag is accepted and used to reject incompatible combinations, but never reaches pub, so the command resolves over the network.

In packages/flutter_tools/lib/src/commands/update_packages.dart at 3.47.5, offline is read once and used only in two guards:

final bool offline = boolArg(_keyOffline);          // :139
if (forceUpgrade && offline) { throwToolExit(...) } // :151
if (cherryPicks.isNotEmpty && offline) { ... }      // :159

Both pub invocations in that file omit it:

Future<void> _pubGet(FlutterProject project, bool enforceLockfile) async =>
    pub.get(context: PubContext.pubGet, project: project,
            enforceLockfile: enforceLockfile);                     // :241

await pub.interactively(<String>['upgrade', '--tighten', '-C', projectTempDir.path],
                        context: PubContext.updatePackages, ...);  // :293

Pub.get has the parameter and forwards it (lib/src/dart/pub.dart:151, and if (offline) '--offline' at :342); other callers such as create.dart and widget_preview.dart do pass it.

Observed with the network unreachable, a pub cache holding every package the lockfile names, and PUB_HOSTED_URL left at its default:

$ flutter update-packages --offline
Resolving dependencies...
Downloading packages...
ClientException with SocketException: Connection failed
  (OS Error: Network is unreachable, errno = 101), address = pub.dev, port = 443,
  uri=https://pub.dev/api/packages/archive/advisories
Failed to update packages.

pub's own advisories fetch is offline-guarded (_fetchAdvisories, third_party/pkg/pub/lib/src/source/hosted.dart:566, "Don't attempt to fetch advisories in --offline mode"), which is consistent with pub simply never being told it is offline here.

Two further observations from the same environment, for whoever picks this up:

  • With --offline reaching pub, the command still does not complete: it re-resolves rather than honoring the lockfile, and had not finished after 15 minutes. dart pub get --offline against the same cache returns in under a second.
  • flutter doctor similarly runs dart pub ... get for packages/flutter_tools without --offline; with no network that step fails and doctor still exits 0.

Context: packaging the SDK for Yocto, where builds run with the network off by policy.

Activity

  1. added
    in triagePresently being triaged by the triage team
    toolAffects the "flutter" command-line tool. See also t: labels.
    team-toolOwned by Flutter Tool team
    and removed
    in triagePresently being triaged by the triage team
    on Sep 28, 2026
  2. puneetkukreja98 commented on Sep 28, 2026

    @puneetkukreja98
    Contributor

    @jwinarske Thanks for reporting this, routing this to team-tool for further investigation.

  3. self-assigned this
    on Oct 2, 2026
  4. added
    triaged-toolTriaged by Flutter Tool team
    and removed
    toolAffects the "flutter" command-line tool. See also t: labels.
    team-toolOwned by Flutter Tool team
    on Oct 2, 2026
  5. reopened this on Oct 16, 2026
  6. flutter-triage-bot commented on Oct 19, 2026

    @flutter-triage-bot

    The triaged-tool label is irrelevant if there is no team-tool label or fyi-tool label.

  7. github-actions commented on Nov 6, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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