Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`flutter update-packages --offline` does not pass --offline to pub

Chiusa Adatta ai principianti
#193,423 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
dart
Ambito
cli

Direzione di ricerca

Inizia in packages/flutter_tools/lib/src/commands/update_packages.dart, nella gestione del flag offline e nelle invocazioni di _pubGet e pub.interactively. Leggi Pub.get in lib/src/dart/pub.dart, quindi verifica che entrambi i percorsi di risoluzione dei pacchetti rispettino offline e che update-packages venga completato senza accesso alla rete utilizzando la configurazione descritta con i pacchetti memorizzati nella cache.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

team-tool tool

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.

Lingua principale
Dart
Stelle
179k
Fork
33.2k
Merge medio
2g 19h
PR unite (30g)
400

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di flutter/flutter

Tutte le issue di flutter/flutter

Issue simili

Altre issue su Dart

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.