Is there a workaround for pub dependency resolution through proxies?

独自空忆成欢 提交于 2019-12-22 10:48:56

问题


I'm trying to play with https://github.com/dart-lang/web-ui-code-lab for dart development. If I follow the pdf and open step05, then try to run chat_server.dart, I get this error (my path has no spaces in it, in case that's relevant):

dart --enable-checked-mode bin/chat_server.dart

Unable to open file: path/to/web-ui-code-lab-master/step05/bin/packages/dart_chat/file_logger.dart'file:///path/to/dart/web-ui-code-lab-master/step05/bin/chat_server.dart': Error: line 5 pos 1: library handler failed
import 'package:dart_chat/file_logger.dart' as log;
^

I presume this means that there are some missing dependencies, but I can't run pub install because I'm behind a corporate http proxy:

Running pub install ...
Pub install failed, [1] Resolving dependencies...
Timed out trying to find package "web_ui 0.2.8+6" at http://pub.dartlang.org.

Hence, I started looking for a temporary workaround for pub dependency resolution. I tried changing the pubspec.yaml to go through the git:// protocol instead of http (which won't resolve without going through the proxy):

name: dart_chat
description: This is a chat app written in Dart using the Dart Web UI package

dependencies:
  web_ui:
    git: git://github.com/dart-lang/web-ui.git

I get further than before with pub install, so I think it successfully went through the git protocol and is trying to resolve web_ui's dependencies, but unfortunately doing so fails on web_ui's dependency for logging (which looks like it's still going through http://):

Running pub install ...
Pub install failed, [1] Resolving dependencies...
Timed out trying to find package "logging 0.2.7" at http://pub.dartlang.org.

It looks like I can't change the yaml to use the sdk's logging dependency either:

logging:
    sdk: logging

because that's an incompatible source with web_ui:

Pub install failed, [1] Resolving dependencies...
Incompatible dependencies on 'logging':
- 'dart_chat' depends on it from source 'sdk'
- 'web_ui' depends on it from source 'hosted'

Is there any other way to get around this proxy issue with the current dev tools? Could I mirror pub.dartlang.org somehow? Or mirror the git repositories for each dependency? Thanks.


回答1:


You said that you're using a Mac. If it's a laptop, why don't you try doing it from home? I'll notify the author of pub about this issue to see if he has any suggestions.




回答2:


Currently there is no way to set a proxy in the Dart Editor, you can star this issue to check when it will be available.

I found a workaround to run the Pub install/update behind a proxy: in Windows, you can acess the "Environment variables" and add a variable named HTTP_PROXY with the value

https://USER:PASSWORD@my.proxy.adress:PORT


来源:https://stackoverflow.com/questions/13849336/is-there-a-workaround-for-pub-dependency-resolution-through-proxies

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!