Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get packages failed behind corporate proxy #2111

Open
AndreCahyaS opened this issue Mar 28, 2019 · 3 comments
Open

get packages failed behind corporate proxy #2111

AndreCahyaS opened this issue Mar 28, 2019 · 3 comments
Labels
network-issue-proxy Issues about using a local proxy for network

Comments

@AndreCahyaS
Copy link

Hello,
I'm sorry to open a new issue if this is actually a dup, but I've not found any solution to my issue for weeks reading all the possibly related issues already submitted, and I feel there's nothing exactly like mine.

I'm using flutter and I encountered a problem when I'm trying to get packages (flutter packages get),flutter upgrade, and anything that has something to do with fetching packages if I'm behind a corporate proxy that needs authentication.
I still can't fetch the packages even if I've set the environment variables as such :
http_proxy=http://user%40name:password@hostname:port
https_proxy=http://user%40name:password@hostname:port
(n.b. %40 since my username have '@' character)

FYI, I can access pub.dartlang.org just fine in the browser,
I could also access every link that was suggested in another related issues like mine.

This is my log from flutter run --verbose :

D:\__PROJECT\_FLUTTER\hobihobi>flutter run --verbose
[  +19 ms] executing: [C:\Development\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[  +38 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [C:\Development\flutter\] git rev-parse --abbrev-ref HEAD
[  +21 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[        ] executing: [C:\Development\flutter\] git ls-remote --get-url origin
[  +20 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[        ] executing: [C:\Development\flutter\] git log -n 1 --pretty=format:%H
[  +21 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[        ] 8661d8aecd626f7f57ccbcb735553edc05a2e713
[        ] executing: [C:\Development\flutter\] git log -n 1 --pretty=format:%ar
[  +20 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[        ] 6 weeks ago
[        ] executing: [C:\Development\flutter\] git describe --match v*.*.* --first-parent --long --tags
[  +21 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.2.1-0-g8661d8aec
[  +75 ms] executing: C:\Development\android-sdk-windows\platform-tools\adb devices -l
[  +12 ms] Exit code 0 from: C:\Development\android-sdk-windows\platform-tools\adb devices -l
[        ] List of devices attached
           f612893c0904           device product:vince model:Redmi_5_Plus device:vince transport_id:1
[  +21 ms] Running "flutter packages get" in hobihobi...
[   +5 ms] Using C:\Development\flutter\.pub-cache for the pub cache.
[   +6 ms] executing: [D:\__PROJECT\_FLUTTER\hobihobi\] C:\Development\flutter\bin\cache\dart-sdk\bin\pub.bat --verbosity=warning --verbose get
--no-precompile
[ +248 ms] Proxy failed to establish tunnel (407 Proxy Authentication Required)
[   +9 ms] package:pub/src/source/hosted.dart 341:7          BoundHostedSource._throwFriendlyError
[   +2 ms] package:pub/src/source/hosted.dart 183:7          BoundHostedSource.describeUncached
[   +7 ms] ===== asynchronous gap ===========================
[   +1 ms] dart:async                                        _AsyncAwaitCompleter.completeError
[   +3 ms] package:pub/src/source/hosted.dart                BoundHostedSource.describeUncached
[        ] ===== asynchronous gap ===========================
[        ] dart:async                                        _asyncErrorWrapperHelper
[        ] package:pub/src/source/hosted.dart                BoundHostedSource.describeUncached
[   +1 ms] package:pub/src/source/cached.dart 39:18          CachedSource.doDescribe
[   +2 ms] ===== asynchronous gap ===========================
[   +5 ms] dart:async                                        _asyncThenWrapperHelper
[   +3 ms] package:pub/src/solver/version_solver.dart        VersionSolver._choosePackageVersion
[        ] package:pub/src/solver/version_solver.dart 97:22  VersionSolver.solve
[   +3 ms] ===== asynchronous gap ===========================
[   +1 ms] dart:async                                        _asyncThenWrapperHelper
[        ] package:pub/src/solver/version_solver.dart        VersionSolver.solve
[   +5 ms] package:pub/src/solver.dart 35:10                 resolveVersions.<fn>
[        ] package:pub/src/log.dart 378:18                   progress
[   +3 ms] package:pub/src/solver.dart 32:10                 resolveVersions
[        ] package:pub/src/entrypoint.dart 200:24            Entrypoint.acquireDependencies
[        ] This is an unexpected error. Please run
[        ]     pub --trace --verbosity=warning --verbose get --no-precompile
[        ] and include the logs in an issue on https://github.com/dart-lang/pub/issues/new
[   +9 ms] Running "flutter packages get" in hobihobi... (completed in 0.3s)
[   +2 ms] "flutter run" took 394ms.
[        ] "flutter run" took 394ms.
pub get failed (1)

#0      throwToolExit (package:flutter_tools/src/base/common.dart:24:3)
#1      pub (package:flutter_tools/src/dart/pub.dart:170:5)
<asynchronous suspension>
#2      pubGet (package:flutter_tools/src/dart/pub.dart:104:13)
<asynchronous suspension>
#3      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:533:13)
<asynchronous suspension>
#4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:482:33)
<asynchronous suspension>
#5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142:29)
<asynchronous suspension>
#6      _rootRun (dart:async/zone.dart:1124:13)
#7      _CustomZone.run (dart:async/zone.dart:1021:19)
#8      _runZoned (dart:async/zone.dart:1516:10)
#9      runZoned (dart:async/zone.dart:1463:12)
#10     AppContext.run (package:flutter_tools/src/base/context.dart:141:18)
<asynchronous suspension>
#11     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:473:20)
#12     CommandRunner.runCommand (package:args/command_runner.dart:196:27)
<asynchronous suspension>
#13     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:396:21)
<asynchronous suspension>
#14     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142:29)
<asynchronous suspension>
#15     _rootRun (dart:async/zone.dart:1124:13)
#16     _CustomZone.run (dart:async/zone.dart:1021:19)
#17     _runZoned (dart:async/zone.dart:1516:10)
#18     runZoned (dart:async/zone.dart:1463:12)
#19     AppContext.run (package:flutter_tools/src/base/context.dart:141:18)
<asynchronous suspension>
#20     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:356:19)
<asynchronous suspension>
#21     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:111:29)
#22     new Future.sync (dart:async/future.dart:224:31)
#23     CommandRunner.run (package:args/command_runner.dart:111:11)
#24     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:242:18)
#25     run.<anonymous closure> (package:flutter_tools/runner.dart:60:20)
<asynchronous suspension>
#26     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142:29)
<asynchronous suspension>
#27     _rootRun (dart:async/zone.dart:1124:13)
#28     _CustomZone.run (dart:async/zone.dart:1021:19)
#29     _runZoned (dart:async/zone.dart:1516:10)
#30     runZoned (dart:async/zone.dart:1463:12)
#31     AppContext.run (package:flutter_tools/src/base/context.dart:141:18)
<asynchronous suspension>
#32     runInContext (package:flutter_tools/src/context_runner.dart:48:24)
<asynchronous suspension>
#33     run (package:flutter_tools/runner.dart:51:10)
#34     main (package:flutter_tools/executable.dart:52:9)
<asynchronous suspension>
#35     main (file:///E:/b/rr/tmpdrhwmy/w/archive/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#36     _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:298:32)
#37     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)`

My flutter doctor result is this :
image

Is the only way I could work on this is by using this solution below?
https://stackoverflow.com/questions/16808883/dart-pub-fail-behind-a-proxy-is-there-a-way-to-install-the-packages-manually
It's pretty bothersome if I need to remote my computer at home everytime I'm updating my dependencies, especially when I still have another dependency issues.

Thank you before, please tell me if you need more information on this.

@jonasfj
Copy link
Member

jonasfj commented Mar 28, 2019

Try to write a small a small program using dart:io and get that to work. If you can't get the following to work then there is a problem with how your HTTP proxy is configured, how you are supplying credentials, or how dart:io handles %40 in it's encoding, or how your proxy handles %40 in it's code (not unlikely)..

import 'dart:io';
import 'dart:convert';

Future<void> main() async {
  final client = HttpClient();
  final uri = Uri.parse('https://pub.dartlang.org/api/packages/test');
  final req = await client.getUrl(uri);
  final res = await req.close();
  final raw = await res.toList().then((l) => l.expand((i) => i).toList());
  final out = json.fuse(utf8).decode(raw) as Map<String, dynamic>;
  final ver = out['latest']['version'];
  print('Latest version of test package is $ver');
  client.close();
}

I'm not sure encoding with %40 will work (I have no idea).. you'll likely have to debug dart:io for this to work.


I'm not sure how much we can help you debug specific cases like this, as it could be so many things...
From the stack trace it looks as though your proxy might complain about missing authentication...

@alexanderconner
Copy link

Also experiencing this issue within a corporate proxy, same logged error and http proxy is set according to flutter doctor.

@Koushikphy
Copy link

having the same problem in Linux bash terminal

pub get failed (server unavailable) -- attempting retry 2 in 2 seconds...
Proxy failed to establish tunnel (407 Proxy Authentication Required)

I've used this #2111 (comment) and it throws this error

Unhandled exception:
HttpException: Proxy failed to establish tunnel (407 Proxy Authentication Required), uri = //pub.dartlang.org:443

Other things like apt, browser works fine with the proxy but flutter worn't. Note: my proxy credentials have one space and one @ that I replace with %20 and %40 .

@sigurdm sigurdm added the network-issue-proxy Issues about using a local proxy for network label Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
network-issue-proxy Issues about using a local proxy for network
Projects
None yet
Development

No branches or pull requests

5 participants