flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.55k stars 27.33k forks source link

flutter pub get return `Package not available (authorization failed).` error! #129518

Closed parsadoc closed 1 year ago

parsadoc commented 1 year ago

Is there an existing issue for this?

Steps to reproduce

running flutter pub get on version 3.10.5 stable

Expected results

it should install dependencies successfully.

Actual results

After upgrading to Flutter 3.10.5, running flutter pub get or dart pub get return the below error:

> flutter packages get
Resolving dependencies... (3.0s)
Package not available (authorization failed).

Code sample

Code sample ```dart [Paste your code here] ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console > flutter packages get Resolving dependencies... (3.0s) Package not available (authorization failed). ```

Flutter Doctor output

Doctor output ```console Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.19045.3086], locale en-US) [√] Windows Version (Installed version of Windows is version 10 or higher) [!] Android toolchain - develop for Android devices (Android SDK version 33.0.1) X cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. X Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for more details. [√] Chrome - develop for the web [!] Visual Studio - develop for Windows (Visual Studio Enterprise 2022 17.5.1) X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components: MSVC v142 - VS 2019 C++ x64/x86 build tools - If there are multiple build tool versions available, install the latest C++ CMake tools for Windows Windows 10 SDK [√] Android Studio (version 2021.3) [√] VS Code (version 1.79.2) [√] Connected device (3 available) [√] Network resources ! Doctor found issues in 2 categories. ```
parsadoc commented 1 year ago

I can't find anything about this error on the web or even in dart or flutter documentation!

darshankawar commented 1 year ago

Thanks for the report @parsadoc I am unable to replicate the behavior you are seeing upon running flutter pub get. Are you consistently getting the error everytime you run the command ? Did you add any community package after which this error started to occur or just upgraded to latest stable ? Can you run flutter pub get -v and see if you get any more details on the error that you can provide here ?

YusnelG commented 1 year ago

Hello good, I want to comment that the same thing happened to me when installing any package and when testing with vpn it worked perfectly.

yasinrahmatian commented 1 year ago

run : flutter pub get -v

easazade commented 1 year ago

@parsadoc We live in Iran so by default Google does not allow us to use many of its APIs. even though they are free. so we use VPNs. but VPNs these days don't work like before.

I think the problem is that Google APIs flag or filter the VPN IPs we use. because literally, I can open any website. But when it comes to fetching Flutter dependencies, I've been getting 403 since this morning. I send the same link that Flutter tries to fetch to my colleague in Germany and he can download it, but I get 403 or 404.

for example below link is a pub package. but I cannot open it and I get a 403 and a message that this service is not available in my country. https://storage.googleapis.com/dartlang-pub-public-packages/packages/fhir-0.9.3.tar.gz Untitled

and for native dependencies that are on Google servers, I get the below error

awd

This may not be the place to ask this question. But Flutter is open-source why should I not be able to use it freely in my country? I get there are sanctions and all. but it's open source. GitHub's free/open-source services were not available in Iran and they fixed it. can't folks at Google do that for us?

easazade commented 1 year ago

And When i run flutter pub get -v

.
.
.
.
.
.
SLVR: Version solving took 0:00:08.261752 seconds.
    | Tried 1 solutions.
FINE: Resolving dependencies finished (8.286s).
IO  : Get package from https://pub.dartlang.org/packages/serverpod_auth_email_flutter/versions/1.1.1.tar.gz.
FINE: Downloading serverpod_auth_email_flutter 1.1.1...
IO  : Created temp directory /var/folders/zg/g1nhxgfj04l20_dw92rp3lc80000gn/T/pub_ZJqPS0
IO  : HTTP GET https://pub.dartlang.org/packages/serverpod_auth_email_flutter/versions/1.1.1.tar.gz
    | X-Pub-OS: macos
    | X-Pub-Command: get
    | X-Pub-Session-ID: EED009EF-FE1D-4486-9FA6-A9AD43CFD2BD
    | X-Pub-Environment: flutter_cli:get
    | X-Pub-Reason: direct
    | user-agent: Dart pub 3.0.5
IO  : HTTP response 403 Forbidden for GET https://pub.dartlang.org/packages/serverpod_auth_email_flutter/versions/1.1.1.tar.gz
    | took 0:00:01.655992
    | alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
    | cache-control: private, max-age=0
    | date: Fri, 30 Jun 2023 21:46:41 GMT
    | content-length: 193
    | x-guploader-uploadid: ADPycdtnuPR6D7xoJWse4mrVL-UYeuz_zz60mht6aqeWMIkH812sdFcNj9X149d7kCcUTIJ74xRhkIwrvkeTBdFdQ3oP9bByy7N1
    | content-type: application/xml; charset=UTF-8
    | server: UploadServer
    | expires: Fri, 30 Jun 2023 21:46:41 GMT
IO  : Deleting directory /private/var/folders/zg/g1nhxgfj04l20_dw92rp3lc80000gn/T/pub_ZJqPS0.
ERR : Package not available (authorization failed).
FINE: Exception type: PackageNotFoundException
FINE: package:pub/src/source/hosted.dart 1356:7              HostedSource._throwFriendlyError
    | package:pub/src/source/hosted.dart 1193:9              HostedSource._download.<fn>
    | ===== asynchronous gap ===========================
    | dart:async                                             Future.catchError
    | package:pub/src/utils.dart 113:52                      captureErrors.wrappedCallback
    | package:stack_trace                                    Chain.capture
    | package:pub/src/utils.dart 126:11                      captureErrors
    | package:pub/src/command.dart 198:13                    PubCommand.run
    | package:args/command_runner.dart 212:27                CommandRunner.runCommand
    | package:dartdev/dartdev.dart 226:30                    DartdevRunner.runCommand
    | package:args/command_runner.dart 122:25                CommandRunner.run.<fn>
    | dart:async                                             new Future.sync
    | package:args/command_runner.dart 122:14                CommandRunner.run
    | package:dartdev/dartdev.dart 58:29                     runDartdev
    | /opt/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart 11:9  main
---- End log transcript ----
IO  : Writing 2705143 characters to text file /Users/alireza/.pub-cache/log/pub_log.txt.
MSG : Logs written to /Users/alireza/.pub-cache/log/pub_log.txt.
[+10596 ms] pub failed
                     command: "/Users/alireza/flutter/bin/cache/dart-sdk/bin/dart pub --suppress-analytics get -v --example --directory ."
                     pub env: {
                       "FLUTTER_ROOT": "/Users/alireza/flutter",
                       "PUB_ENVIRONMENT": "flutter_cli:get",
                     }
                     exit code: 69

[   +5 ms] "flutter get" took 10,670ms.
[   +1 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _DefaultPub._runWithStdioInherited (package:flutter_tools/src/dart/pub.dart:447:7)
           <asynchronous suspension>
           #2      _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:530:5)
           <asynchronous suspension>
           #3      PackagesGetCommand.runCommand (package:flutter_tools/src/commands/packages.dart:303:7)
           <asynchronous suspension>
           #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1336:27)
           <asynchronous suspension>
           #5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #6      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:296:9)
           <asynchronous suspension>
           #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #9      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:244:5)
           <asynchronous suspension>
           #10     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:91:9)
           <asynchronous suspension>
           #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #12     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>

[   +3 ms] Running 0 shutdown hooks
[   +1 ms] Shutdown hooks complete
[        ] exiting with code 69
NekonexDev commented 1 year ago

As a result, I can say that flutter pub does not work in regions under US sanctions such as Crimea, Lugansk and Donetsk regions, as well as Iran

plinkr commented 1 year ago

As a result, I can say that flutter pub does not work in regions under US sanctions such as Crimea, Lugansk and Donetsk regions, as well as Iran

Also it doesn't work on Cuba.

easazade commented 1 year ago

that's my whole point. it's open source so there is no point for flutter pub to be unavailable in Countries under US sanctions.

darshankawar commented 1 year ago

Checkout this link for further reference.

yazanalkamsheh commented 1 year ago

Is there an existing issue for this?

Steps to reproduce

running flutter pub get on version 3.10.5 stable

Expected results

it should install dependencies successfully.

Actual results

After upgrading to Flutter 3.10.5, running flutter pub get or dart pub get return the below error:

> flutter packages get
Resolving dependencies... (3.0s)
Package not available (authorization failed).

Code sample

Code sample

Screenshots or Video

Screenshots / Video demonstration

Logs

Logs

Flutter Doctor output

Doctor output

Looks like you are in a banned country Solution: Run proton vpn and it will work properly

github-actions[bot] commented 1 year ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones. Thanks for your contribution.

arash28134 commented 1 year ago

In Iran, even most popular VPNs do not work. however, I found a solution for this that should work in any banned region. try launching pub using proxychains package: proxychains flutter pub get before that, you need to configure /etc/proxychains.conf to use a proxy (a local socks5 proxy if you're in Iran since normal proxies constantly get flagged) so you need to put something like this at the end of the config file: socks5 127.0.0.1 1080 (protocol) (ip) (port)

the package should be available in pretty much any distro.

if the problem persists, you can comment out proxy_dns in the same config file and try again. (disabling it fixes most of the problems with proxychains)

NaVaB1331 commented 1 year ago

In my opinion, the best thing is to set DNS It works well for me😏

github-actions[bot] commented 1 year ago

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.