简体   繁体   English

如何为gem设置代理服务器?

[英]How can I set a proxy server for gem?

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, 请帮我,

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

您需要在命令提示符下写入此内容:

set HTTP_PROXY=http://your_proxy:your_port

您需要添加http_proxyhttps_proxy所描述的环境变量这里

In Addition to @Yifei answer. 除了@Yifei的答案。 If you have special character like @, &, $ 如果你有像@,&,$这样的特殊角色

You have to go with percent-encode | 你必须使用百分比编码 | encode the special characters. 编码特殊字符。 Eg instead of this: 例如,而不是这个:

http://foo:B@r@http-gateway.domain.org:80

you write this: 你写这个:

http://foo:B%40r@http-gateway.domain.org:80

So @ gets replaced with %40 . 所以@被替换为%40

您可以尝试export http_proxy=http://your_proxy:your_port

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. 设置http_proxy和https_proxy时,您可能还需要在代理同一侧的URL上使用no_proxy。 https://msdn.microsoft.com/en-us/library/hh272656(v=vs.120).aspx https://msdn.microsoft.com/en-us/library/hh272656(v=vs.120).aspx

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM