Bel*_*ell 47 ruby github bundler
我正在尝试构建一个rails项目,因为我正在处理的主机无法访问Internet上的git://协议(端口9418)我得到的错误就像
Fetching git://github.com/pivotal/jasmine.git
fatal: unable to connect to github.com:
github.com[0: 192.30.252.130]: errno=Connection refused
Run Code Online (Sandbox Code Playgroud)
跑步的时候bundle install.
GemFile中的相关行没有指定git://作为协议,它只是指向GitHub作为gem的源代码
gem 'jasmine', :github => 'pivotal/jasmine-gem'
Run Code Online (Sandbox Code Playgroud)
我需要做些什么来使捆绑器使用https://而不是git://从GitHub中提取宝石?
编辑:
除了编辑GemFile中的每个受影响的行之外,还有其他方法吗?如果项目的GemFile更新,我宁愿避免任何合并问题.
Bel*_*ell 54
Git使用url..insteadOf配置选项提供URL重写功能.
因此,要建立与github.com的所有连接,请使用https://而不是git://
git config --global url."https://github.com".insteadOf git://github.com
Run Code Online (Sandbox Code Playgroud)
该--global开关设置为当前用户的所有操作的git的配置选项,所以有时它可能是太冒昧.但它确实避免在当前项目中更改git配置.
Agi*_*gis 37
你可以做:
gem 'jasmine', git: 'https://github.com/pivotal/jasmine-gem.git'
Run Code Online (Sandbox Code Playgroud)
mat*_*ias 14
如果你只想在一个Gemfile中的所有gems,你可以在文件的顶部添加这些行:
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
Run Code Online (Sandbox Code Playgroud)
或者你可以使用bundle config github.https true.但这只会影响您当前的环境.
小智 9
如果你要部署到heroku,你可以添加BUNDLE_GITHUB__HTTPS(注意双下划线)作为环境变量并将其设置为true(Settings在该Config Vars部分选项卡下的heroku应用程序的仪表板中).这会将协议从切换git://到https://所有这些请求.