"flutter pub get" can't get dependency plugins

17,629

Solution 1

From yesterday, there is some problem with storage.googleapis.com in Bangladesh.

First I thought this is maybe an issue with Google's Infrastructure.
But, after some time I realized that it's an issue with BTCL.

To overcome this issue, you can use a VPN tool and re-run your project.
I used Hotspot Sheild VPN and after that everything was good.

Remember that, the free version limit is 500 MB/Day

I hope this will also work for you.

Solution 2

'flutter pub get' tries to fetch your plugins that you have declared in your pubspec.yaml and by default it makes a GET request to pub.dev or https://pub.dartlang.org. So if either https://pub.dartlang.org or storage.googleapis.com is blocked by your isp or your company's firewall you wont be able to complete packages get & hence wont be able to build your flutter project. Rather than using the vpn, I prefer using a mirror repository. You can simply change or set two environment varibles with a mirror link like mentioned below. After that 'flutter pub get' command will try to fetch your packages from the specific mirror link. The variables and the links are - * PUB_HOSTED_URL=https://pub.flutter-io.cn * FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

For windows, use these commands in cmd to set the variables in your project environment:

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

Make sure to apply these commands in your project directory in cmd and use 'flutter pub get' from that specific cmd. You can check if the variable is set or not by applying:

echo %PUB_HOSTED_URL% 

The output should be the URL that you just set.

These variables are set only for this environment and will be cleared when you close this terminal. So for windows, if you set these variables in your system user environment then you will be able to use 'flutter pub get' and fetch packages from the china mirror sites at any time.

For mac, export the variables in your bash_profile like this:

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

After this you should be able to apply flutter pub get successfully. (remeber to source your bash_profile after setting a variable)

After all this, if you still can't get the packages: * Delete pubspec.lock file from your project. * Restart your PC. * Check by using echo command to see PUB_HOSTED_URL & FLUTTER_STORAGE_BASE_URL environment variables are set properly or not.

If these variables are set, flutter sdk will try to fetch packages from the mirror site you have set by this variable. If these variables are not present in the workspace environment then flutter sdk will try to fetch the packages using its default urls mentioned earlier.

N.B: When it wasnt working for me, I got frustated and reinstalled flutter sdk and then set these variables in my environment and deleted pubspec.lock file from the project. And Eureka !! It worked for me. After that, with some digging I found out that I didnt have to uninstall & install flutter again.

Hope you will be able to get the packages now without a vpn and anything else. Best of luck.

Solution 3

  1. Updating Flutter will not work
  2. Restarting PC will not work
  3. Creating new project and running pub get will not work.

If you are from Bangladesh, then only solution is to use VPN for the time being. There are some network issue with BTCL which is causing the issue.

Share:
17,629

Related videos on Youtube

Md Mahmudul Islam
Author by

Md Mahmudul Islam

Think simple do innovative. I am from: Bangladesh Folow me: Portfolio LinkedIn Github Facebook

Updated on August 21, 2022

Comments

  • Md Mahmudul Islam
    Md Mahmudul Islam over 1 year

    I've been trying to get dependencies for my Flutter project on Windows but it's taking a long time and after a while , it shows this error in 'messages' bar.

    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...
    

    I am trying to solve this problem some ways but failed to solve. I am doing flutter clean, flutter upgrade and restart android studio at the end same problem happen.

    It was working fine before I add url_launcher inside the dependencies in my project.

    Here is my pubspec.yaml file:

    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/
    


    After running "flutter pub get --verbose" shows:

    [  +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
    
    

    What is the problem and how to solve it?

  • Nahiyan
    Nahiyan almost 4 years
    500 MB per day? I downloaded over 2 gigs as a free user using Hotspot Shield in just few hours today without any issue. Mind referencing where you got this information?
  • Nahiyan
    Nahiyan almost 4 years
    Is it possible that it's a ban on Google's storage API? It's here for a long time already.
  • Shariful Islam Mubin
    Shariful Islam Mubin almost 4 years
  • Benyamin Beyzaie
    Benyamin Beyzaie over 2 years
    it won't work if it is related to dart analysis