在 Windows 中通过代理创建一个新的 rails 3 项目 [英] Creating a new rails 3 project over a proxy in windows
问题描述
我的电脑在代理上工作.所以为了安装 gems,我使用以下命令
My computer works on a proxy. So in order to install gems I use the following command
gem install -p http//#{proxy-server}:#{port} rails
如果我使用普通的 gem install 命令,我会收到一个错误 could not find gem
.我今天安装了 rails 3.1 并尝试创建一个新项目.在创建文件的一半过程中,生成器开始执行 run bundle install
并最终给出相同的错误
If i use the normal gem install command, I get an error could not find gem
. I installed rails 3.1 today and tried to create a new project. Half the way while creating the files, the generator started executing run bundle install
and ended up giving the same error
Fetching source index for http://rubygems.org/
Could not reach rubygems repository http://rubygems.org/
Could not find gem 'turn (>= 0, runtime)' in any of the gem sources listed in your Gemfile.
生成器正在尝试在没有代理的情况下安装一些 gem.如何覆盖此现有功能?我希望生成器使用 gem install -p http//#{proxy-server}:#{port} #{gem}
而不是 gem install #{gem}
The generator is trying to install some gems without proxy. How can I override this existing functionality? I want the generator to use gem install -p http//#{proxy-server}:#{port} #{gem}
instead of gem install #{gem}
推荐答案
将给定的选项添加到您的 gemrc 文件
Add the given option to your gemrc file
gem: -p http//#{proxy-server}:#{port}
在 unix 下,这个文件位于 ~/.gemrc
下,对于 windows 我不知道,但根据 这个答案应该是
Under unix this file is located under ~/.gemrc
, for windows I don't know, but according to this answer should be
# Under windows XP
C:\Documents and Settings\All Users\Application Data\gemrc
# Under Windows Vista/Seven
C:\ProgramData\gemrc for windows Vista/Seven
如果 rc 文件不存在,则需要创建.
The rc file needs to be created if not present.
这篇关于在 Windows 中通过代理创建一个新的 rails 3 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!