web-dev-qa-db-fra.com

"flutter pub get" ne peut pas obtenir de plug-ins de dépendance sous Windows

J'ai essayé d'obtenir des dépendances pour mon projet Flutter sur Windows mais cela prend beaucoup de temps et après un certain temps, cela montre cette erreur dans la barre des `` messages ''.

Running "flutter pub get" in badhan_blood_bank...               
OS Error: The semaphore timeout period has expired.

, errno = 121, address = storage.googleapis.com, port = 53515

pub get failed (server unavailable) -- attempting retry 1 in 1 second...

J'essaie de résoudre ce problème de certaines manières mais je n'ai pas réussi à le résoudre. Je fais le flutter clean, la mise à niveau du flutter et le redémarrage Android studio à la fin, le même problème se produit.

Cela fonctionnait bien avant d'ajouter url_launcher dans les dépendances de mon projet.

Voici mon fichier pubspec.yaml:

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  firebase_auth: ^0.15.5+2
  flutter_facebook_login: ^3.0.0
  flutter_icons: ^1.0.0+1
  flutter_spinkit: ^4.1.2
  firebase_database: ^3.1.3
  google_maps_flutter: ^0.5.25
  geolocator: ^5.3.0
  intl: ^0.16.1
  curved_navigation_bar: ^0.3.2
  fluttertoast: ^4.0.1
  url_launcher: ^5.4.2



dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

  assets:
  - images/


Après avoir exécuté "flutter pub get --verbose" montre:

[  +27 ms] executing: [C:\src\flutter\flutter\] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +64 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 0b8abb4724aa590dd0f429683339b1e045a1594d
[        ] executing: [C:\src\flutter\flutter\] git describe --match v*.*.* --first-parent --long --tags
[  +56 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.12.13+hotfix.8-0-g0b8abb472
[   +7 ms] executing: [C:\src\flutter\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[  +41 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] Origin/stable
[        ] executing: [C:\src\flutter\flutter\] git ls-remote --get-url Origin
[  +38 ms] Exit code 0 from: git ls-remote --get-url Origin
[        ] https://github.com/flutter/flutter.git
[  +77 ms] executing: [C:\src\flutter\flutter\] git rev-parse --abbrev-ref HEAD
[  +41 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +48 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +4 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +130 ms] Running "flutter pub get" in badhan_blood_bank...
[   +5 ms] Using C:\src\flutter\flutter\.pub-cache for the pub cache.
[   +1 ms] executing: [D:\@@MyWorks\mahmud\Badhan Blood Bank\badhan_blood_bank\] C:\src\flutter\flutter\bin\cache\Dart-sdk\bin\pub.bat --verbose get
--no-precompile
[ +157 ms] FINE: Pub 2.7.0
[   +3 ms] IO  : Spawning "cmd /c ver" in D:\@@MyWorks\mahmud\Badhan Blood Bank\badhan_blood_bank\.
[   +7 ms] IO  : Finished ver. Exit code 0.
[   +1 ms]     | stdout:
[        ]     | | 
[   +1 ms]     | | Microsoft Windows [Version 10.0.18362.720]
[   +1 ms]     | Nothing output on stderr.
[ +102 ms] MSG : Resolving dependencies...
[   +9 ms] SLVR: fact: badhanbloodbank is 1.0.0+1
[   +5 ms] SLVR: derived: badhanbloodbank
[  +61 ms] SLVR: fact: badhanbloodbank depends on flutter any from sdk
[   +1 ms] SLVR: fact: badhanbloodbank depends on cupertino_icons ^0.1.2
[   +1 ms] SLVR: fact: badhanbloodbank depends on firebase_auth ^0.15.5+2
[   +1 ms] SLVR: fact: badhanbloodbank depends on flutter_facebook_login ^3.0.0
[   +1 ms] SLVR: fact: badhanbloodbank depends on flutter_icons ^1.0.0+1
[   +1 ms] SLVR: fact: badhanbloodbank depends on flutter_spinkit ^4.1.2
[        ] SLVR: fact: badhanbloodbank depends on firebase_database ^3.1.3
[        ] SLVR: fact: badhanbloodbank depends on google_maps_flutter ^0.5.25
[        ] SLVR: fact: badhanbloodbank depends on geolocator ^5.3.0
[        ] SLVR: fact: badhanbloodbank depends on intl ^0.16.1
[        ] SLVR: fact: badhanbloodbank depends on curved_navigation_bar ^0.3.2
[        ] SLVR: fact: badhanbloodbank depends on fluttertoast ^4.0.1
[        ] SLVR: fact: badhanbloodbank depends on url_launcher ^5.4.2
[        ] SLVR: fact: badhanbloodbank depends on flutter_test any from sdk
[        ] SLVR:   selecting badhanbloodbank
[        ] SLVR:   derived: flutter_test any from sdk
[        ] SLVR:   derived: url_launcher ^5.4.2
[   +1 ms] SLVR:   derived: fluttertoast ^4.0.1
[   +1 ms] SLVR:   derived: curved_navigation_bar ^0.3.2
[        ] SLVR:   derived: intl ^0.16.1
[   +1 ms] SLVR:   derived: geolocator ^5.3.0
[   +1 ms] SLVR:   derived: google_maps_flutter ^0.5.25
[   +1 ms] SLVR:   derived: firebase_database ^3.1.3
[        ] SLVR:   derived: flutter_spinkit ^4.1.2
[        ] SLVR:   derived: flutter_icons ^1.0.0+1
[        ] SLVR:   derived: flutter_facebook_login ^3.0.0
[        ] SLVR:   derived: firebase_auth ^0.15.5+2
[        ] SLVR:   derived: cupertino_icons ^0.1.2
[        ] SLVR:   derived: flutter any from sdk
[        ] IO  : Get versions from https://pub.dartlang.org/api/packages/url_launcher.
[   +9 ms] IO  : HTTP GET https://pub.dartlang.org/api/packages/url_launcher
[   +2 ms]     | Accept: application/vnd.pub.v2+json
[   +1 ms]     | X-Pub-OS: windows
[        ]     | X-Pub-Command: get
[        ]     | X-Pub-Session-ID: 795584D9-523C-4575-B686-2D496C324C5B
[        ]     | X-Pub-Environment: flutter_cli:get
[   +1 ms]     | X-Pub-Reason: direct
[        ]     | user-agent: Dart pub 2.7.0
[ +934 ms] IO  : HTTP response 200 OK for GET https://pub.dartlang.org/api/packages/url_launcher
[   +5 ms]     | took 0:00:00.938247
[   +2 ms]     | transfer-encoding: chunked
[   +2 ms]     | date: Sun, 29 Mar 2020 19:47:07 GMT
[   +2 ms]     | content-encoding: gzip
[   +2 ms]     | vary: Accept-Encoding
[   +3 ms]     | strict-transport-security: max-age=31536000; preload
[   +3 ms]     | via: 1.1 google
[   +2 ms]     | content-type: application/json
[   +2 ms]     | x-frame-options: SAMEORIGIN
[   +2 ms]     | x-xss-protection: 1; mode=block
[   +2 ms]     | x-content-type-options: nosniff
[   +2 ms]     | server: Dart:io with Shelf
[  +66 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on flutter any from sdk
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on test_api 0.2.11
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on path 1.6.4
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on image 2.1.4
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on quiver 2.0.5
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on stack_trace 1.9.3
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on vector_math 2.0.8
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on archive 2.0.11
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on args 1.5.2
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on async 2.4.0
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on boolean_selector 1.0.5
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on charcode 1.1.2
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on collection 1.14.11
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on convert 2.1.1
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on crypto 2.1.3
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on matcher 0.12.6
[   +2 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on meta 1.1.8
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on pedantic 1.8.0+1
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on petitparser 2.4.0
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on source_span 1.5.5
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on stream_channel 2.0.0
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on string_scanner 1.0.5
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on term_glyph 1.1.0
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on typed_data 1.1.6
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on xml 3.5.0
[        ] SLVR:     selecting flutter_test 0.0.0 from sdk
[        ] SLVR:     derived: xml 3.5.0
[        ] SLVR:     derived: typed_data 1.1.6
[   +1 ms] SLVR:     derived: term_glyph 1.1.0
[        ] SLVR:     derived: string_scanner 1.0.5
[        ] SLVR:     derived: stream_channel 2.0.0
[   +2 ms] SLVR:     derived: source_span 1.5.5
[        ] SLVR:     derived: petitparser 2.4.0
[        ] SLVR:     derived: pedantic 1.8.0+1
[        ] SLVR:     derived: meta 1.1.8
[   +3 ms] SLVR:     derived: matcher 0.12.6
[        ] SLVR:     derived: crypto 2.1.3
[        ] SLVR:     derived: convert 2.1.1
[   +1 ms] SLVR:     derived: collection 1.14.11
[        ] SLVR:     derived: charcode 1.1.2
[        ] SLVR:     derived: boolean_selector 1.0.5
[        ] SLVR:     derived: async 2.4.0
[   +1 ms] SLVR:     derived: args 1.5.2
[   +4 ms] SLVR:     derived: archive 2.0.11
[   +1 ms] SLVR:     derived: vector_math 2.0.8
[   +4 ms] SLVR:     derived: stack_trace 1.9.3
[   +1 ms] SLVR:     derived: quiver 2.0.5
[        ] SLVR:     derived: image 2.1.4
[   +1 ms] SLVR:     derived: path 1.6.4
[   +1 ms] SLVR:     derived: test_api 0.2.11
[   +1 ms] SLVR:     fact: url_launcher >=3.0.0 depends on flutter any from sdk
[        ] SLVR:     fact: url_launcher >=5.4.0 depends on url_launcher_macos ^0.0.1
[   +1 ms] SLVR:     fact: url_launcher >=5.4.1 depends on url_launcher_platform_interface ^1.0.4
[   +1 ms] SLVR:     fact: url_launcher >=5.3.0 depends on url_launcher_web ^0.1.0+1
[   +1 ms] SLVR:       selecting url_launcher 5.4.2
[        ] SLVR:       derived: url_launcher_web ^0.1.0+1
[        ] SLVR:       derived: url_launcher_platform_interface ^1.0.4
[        ] SLVR:       derived: url_launcher_macos ^0.0.1
[   +1 ms] IO  : Get versions from https://pub.dartlang.org/api/packages/url_launcher_web.
[   +1 ms] IO  : HTTP GET https://pub.dartlang.org/api/packages/url_launcher_web
[        ]     | Accept: application/vnd.pub.v2+json
[        ]     | X-Pub-OS: windows
[        ]     | X-Pub-Command: get
[        ]     | X-Pub-Session-ID: 795584D9-523C-4575-B686-2D496C324C5B
[        ]     | X-Pub-Environment: flutter_cli:get
[        ]     | user-agent: Dart pub 2.7.0
[ +429 ms] IO  : HTTP response 200 OK for GET https://pub.dartlang.org/api/packages/url_launcher_web

Quel est le problème et comment le résoudre?

6
Md Mahmudul Islam

'flutter pub get' essaie de récupérer vos plugins que vous avez déclarés dans votre pubspec.yaml et par défaut il envoie une requête GET à pub.dev ou https://pub.dartlang.org . Donc, si https://pub.dartlang.org ou storage.googleapis.com est bloqué par votre fournisseur de services Internet ou le pare-feu de votre entreprise, vous ne pourrez pas compléter les packages get et par conséquent ne pourrez pas créer votre projet de flutter. Plutôt que d'utiliser le vpn, je préfère utiliser un référentiel miroir. Vous pouvez simplement modifier ou définir deux variables d'environnement avec un lien miroir comme mentionné ci-dessous. Après cette commande 'flutter pub get' essaiera de récupérer vos paquets à partir du lien miroir spécifique. Les variables et les liens sont - * PUB_HOSTED_URL = https://pub.flutter-io.cn * FLUTTER_STORAGE_BASE_URL = https://storage.flutter-io.cn

Pour Windows, utilisez ces commandes dans cmd pour définir les variables dans l'environnement de votre projet:

set PUB_HOSTED_URL=https://pub.flutter-io.cn
set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

Assurez-vous d'appliquer ces commandes dans le répertoire de votre projet dans cmd et utilisez 'flutter pub get' à partir de cette cmd spécifique. Vous pouvez vérifier si la variable est définie ou non en appliquant:

echo %PUB_HOSTED_URL% 

La sortie doit être l'URL que vous venez de définir.

Ces variables sont définies uniquement pour cet environnement et seront effacées lorsque vous fermez ce terminal. Donc, pour Windows, si vous définissez ces variables dans votre environnement utilisateur système, vous pourrez à tout moment utiliser "flutter pub get" et récupérer des paquets sur les sites miroirs de porcelaine.

Pour mac, exportez les variables de votre bash_profile comme ceci:

 export PUB_HOSTED_URL=https://pub.flutter-io.cn
 export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

Après cela, vous devriez pouvoir appliquer le flutter pub get avec succès. (rappelez-vous de trouver votre bash_profile après avoir défini une variable)

Après tout cela, si vous ne pouvez toujours pas obtenir les packages: * Supprimez le fichier pubspec.lock de votre projet. * Redémarrez votre PC. * Vérifiez en utilisant la commande echo pour voir que les variables d'environnement PUB_HOSTED_URL & FLUTTER_STORAGE_BASE_URL sont correctement définies ou non.

Si ces variables sont définies, flutter sdk essaiera de récupérer les packages du site miroir que vous avez défini par cette variable. Si ces variables ne sont pas présentes dans l'environnement de l'espace de travail, flutter sdk essaiera de récupérer les packages en utilisant ses URL par défaut mentionnées précédemment.

N.B: Quand cela ne fonctionnait pas pour moi, j'ai été frustré et j'ai réinstallé Flutter SDK, puis j'ai défini ces variables dans mon environnement et j'ai supprimé le fichier pubspec.lock du projet. Et Eureka !! Cela a fonctionné pour moi. Après cela, après avoir creusé, j'ai découvert que je n'avais pas besoin de désinstaller et d'installer à nouveau Flutter.

J'espère que vous serez en mesure d'obtenir les paquets maintenant sans VPN ni rien d'autre. Bonne chance.

0
Mohtasim