Ουι*_*ευα 50 ruby-on-rails bundler gemfile
最近我创建了一个新的Rails 5应用程序,没有git存储库.自动生成的Gemfile包含一个我之前没见过的新块:
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)
它的含义是什么?每个新应用都必须使用它吗?
max*_*max 49
它是一段遗留代码,最有可能被删除.
补充: 它是Bundler中一个错误的解决方法,可以通过HTTP而不是HTTPS加载来自github的源 - 这使得它在中间攻击中容易受到攻击.
git_source
添加一个可以使用的源代码,以便从git存储库而不是包中下载gem rubygems.org
.
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)
当你宣布:
gem 'foo_bar', :github => 'foo/bar'
Run Code Online (Sandbox Code Playgroud)
Bundler将尝试从中下载gem https://github.com/foo/bar.git
.
由于修复这将是一个重大变化,因为它将使任何现有的Gemfile.lock无效,它在Bundler 2.x中得到修复.此时,删除此解决方法应该是安全的.
如果您不想将此代码添加到gemfile但仍希望从github安全地访问gem,则可以使用以下方法:
gem 'foo_bar', git: 'https://github.com/foo/bar.git
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7054 次 |
最近记录: |