【发布时间】:2011-02-18 21:23:37
【问题描述】:
在我的 gemfile 中有这个:
gem "authlogic", :git => "git://github.com/odorcicd/authlogic.git", :branch => "rails3"
如何将它安装为 gem 以便进行测试?
【问题讨论】:
在我的 gemfile 中有这个:
gem "authlogic", :git => "git://github.com/odorcicd/authlogic.git", :branch => "rails3"
如何将它安装为 gem 以便进行测试?
【问题讨论】:
您不需要在本地构建 gem。在您的 gemfile 中,您可以使用 ref、branch 或 tag 指定 github 源。
gem 'rails', git: 'git://github.com/rails/rails.git', ref: '4aded'
gem 'rails', git: 'git://github.com/rails/rails.git', branch: '2-3-stable'
gem 'rails', git: 'git://github.com/rails/rails.git', tag: 'v2.3.5'
然后你运行bundle install 或者简写为bundle。
在此处了解更多信息:http://bundler.io/man/gemfile.5.html#GIT
更新:有a github source identifier。
gem 'country_select', github: 'stefanpenner/country_select'
但是,他们警告不要使用它:NOTE: This shorthand should be avoided until Bundler 2.0, since it currently expands to an insecure git:// URL. This allows a man-in-the-middle attacker to compromise your system.
在 Bundler 2.0 之后,您可以使用 Gemfile 顶部附近的以下语句来解决上述问题:
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
【讨论】:
bundle install 命令,RubyGems 说它正在获取 git repo,并安装了它,但是当我执行 gem list gemname 时,它不会出现在我本地安装的 gems 中。
bundle install 像全局一样安装,或者适用于所有 rubygems。但是,它是按项目执行的,有时是按用户执行的。 github.com/bundler/bundler/issues/3070#issuecomment-46361014
github: 标识符给出了我希望避免的transmits data without encryption 警告。使用https 转换为git: 标识符可能还不够,因为我还需要指定一个分支。
NOTE: This shorthand should be avoided until Bundler 2.0, since it currently expands to an insecure git:// URL. This allows a man-in-the-middle attacker to compromise your system. - 根据link you gave
克隆 Git 存储库。
$ git clone git://github.com/odorcicd/authlogic.git
切换到新目录。
cd authlogic
结帐分支
$ git checkout -b rails3 remotes/origin/rails3
构建 gem。
$ rake build gem
安装 gem。
$ gem install pkg/gemname-1.23.gem
【讨论】:
gem 'rails', :github => 'rails', :branch => '5.0-stable' - 链接:bundler.io/v1.3/git.html
gem build <gem-name>.gemspec 工作。我没有在 Gemfile 中列出 rake。所以rake build gem throw rake 不是捆绑包的一部分。将其添加到 gemfile
我必须修改@janic_ 的答案才能使其正常工作。 希望它能帮助像我这样的其他红宝石新手。
克隆 Git 存储库。
$ git clone git://github.com/odorcicd/authlogic.git
切换到新目录。
$ cd authlogic
结帐分支
$ git checkout -b rails3 remotes/origin/rails3
安装包
$ bundle install
构建 gem。
$ rake build
安装 gem。
$ gem install pkg/gemname-1.23.gem
【讨论】: