dart pub fail behind a proxy - is there a way to install the packages manually?

折月煮酒 提交于 2019-11-27 03:05:55

问题


There is a known issue with using Pub dart in a corporate network using a proxy (on windows machine at least). You cannot even run the samples as they make use of pub to get the packages. if you run the samples first from a network without a proxy, it works perfectly fine (the packages have been installed) when you run them from behind the proxy.

My question is: how can I install the packages manually?

I can of course get them from git for example, but what do I have to do afterward to "install them" I am confused with what goes in the Dart install directory, the user directory and the symlinks that seem to be necessary. May be I missed something but I did not find any good doc about that.

thanks,

f.


回答1:


You can download package files manually, copy them to packages folder and then symlink to it from other places which use them (on Windows Vista and later, you can use mklink command). You can also just copy them everywhere, instead of symlinking, but that complicates maintenance.

Simpler solution, if you have access to full installation from the machine without proxy, is to copy packages folder from there.

Even simpler, I sometimes keep test projects in my dropbox folder, so i just update when I am on my home computer, and it works fine on my office machine behind the proxy.

That being said, I was able to fix the proxy issue by specifying following system environment variables (address/port combination below is made up, use the correct one for your setup):

HTTP_PROXY:  192.168.123.123:1234  
HTTPS_PROXY: 192.168.123.123:1234  

in addition, to enable DartEditor to check for editor updates, add following to your DartEditor.ini file:

-Dhttp.proxyHost=192.168.123.123
-Dhttp.proxyPort=1234

If your proxy uses authentication, than check also following settings (mine doesn't so I can't tell):

-Dhttp.proxyUser=XXX
-Dhttp.proxyPassword=XXX



回答2:


Another way to go is using the command line tools for getting the packages:

(On Windows)

  1. Proxy Settings

    • In the cmd (not persistent):

      SET HTTP_PROXY=proxy:port
      SET HTTPS_PROXY=proxy:port
      
    • Or as Zdeslav Vojkovic suggested - specify system environment variables (persistent).

  2. Go to the sample app folder

    cd <path-to-dart-installation>\samples\angular_todo\
    
  3. Run the required pub command:

    <path-to-dart-installation>\dart-sdk\bin\pub.bat get
    

Project is automatically updated in the dart editor.


Edit: Try as well setting the proxy information as system environment variables, but using lower case e.g.

http_proxy=proxy:port
https_proxy=proxy:port

As far I as know Windows environment variables are not case sensitive. However dart editor seems to make difference.



来源:https://stackoverflow.com/questions/16808883/dart-pub-fail-behind-a-proxy-is-there-a-way-to-install-the-packages-manually

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