windows 如何为 gem 设置代理服务器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22059670/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I set a proxy server for gem?
提问by user3358928
I am unable to install SASS through command prompt.
我无法通过命令提示符安装 SASS。
I tried below steps
我尝试了以下步骤
c:\gem install sass
I am getting below error:
我收到以下错误:
ERROR: Could not find a valid gem 'sass' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2) (https://rubygems.org/latest_specs.4.8.gz)
Please help me,
请帮我,
回答by Yifei
For http/https proxy with or without authentication:
对于带有或不带有身份验证的 http/https 代理:
Run one of the following commands in cmd.exe
在 cmd.exe 中运行以下命令之一
set http_proxy=http://your_proxy:your_port
set http_proxy=http://username:password@your_proxy:your_port
set https_proxy=https://your_proxy:your_port
set https_proxy=https://username:password@your_proxy:your_port
回答by Dayli Suarez Sanchez
You need to write this in the command prompt:
您需要在命令提示符中写入:
set HTTP_PROXY=http://your_proxy:your_port
回答by user3565373
回答by Ravi Parekh
In Addition to @Yifei answer. If you have special characterlike @, &, $
除了@Yifei 的回答。如果你有@、&、$ 等特殊字符
You have to go with percent-encode| encodethe special characters. E.g. instead of this:
你必须使用百分比编码| 对特殊字符进行编码。例如,而不是这样:
http://foo:B@[email protected]:80
you write this:
你这样写:
http://foo:B%[email protected]:80
So @
gets replaced with %40
.
所以@
被替换为%40
.
回答by RolandASc
None of the answers here actually helped my case (proxy + password), instead I found a solution on a Github issue:
这里的所有答案实际上都没有帮助我的案例(代理 + 密码),相反,我在 Github 问题上找到了解决方案:
https://github.com/rubygems/rubygems/issues/1068
https://github.com/rubygems/rubygems/issues/1068
Basically I had to set three variables:
基本上我必须设置三个变量:
set http_proxy=proxy_ip:port
set http_proxy_user=user
set http_proxy_pass=password
回答by Vincent H Guyo
You can try export http_proxy=http://your_proxy:your_port
你可以试试 export http_proxy=http://your_proxy:your_port
回答by Ion Freeman
When setting http_proxy and https_proxy, you are also probably going to need no_proxy for URLs on the same side of the proxy. https://msdn.microsoft.com/en-us/library/hh272656(v=vs.120).aspx
在设置 http_proxy 和 https_proxy 时,您可能还需要 no_proxy 用于代理同一侧的 URL。https://msdn.microsoft.com/en-us/library/hh272656(v=vs.120).aspx