【问题标题】:Installing a Ruby gem from a Github repository using Chef?使用 Chef 从 Github 存储库安装 Ruby gem?
【发布时间】:2013-10-14 19:09:00
【问题描述】:

有没有办法从其 Github 存储库(或者,更具体地说,一个 fork)而不是从 Rubygems 安装 Ruby gem?

我试过了

 gem_package 'some_gem' do
  source 'git://github.com:user/some_gem.git'
end

我明白了

Gem::Exception
--------------
Cannot load gem at [git://github.com:user/some_gem.git] in /


Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/some_recipe/recipes/default.rb

 15: gem_package 'some_gem' do
 16:   source 'git://github.com:user/some_gem.git'
 17: end
 18: 



Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/some_gem/recipes/default.rb:15:in `from_file'

gem_package("some_gem") do
  provider Chef::Provider::Package::Rubygems
  action :install
  retries 0
  retry_delay 2
  package_name "some_gem"
  source "git://github.com:user/some_gem.git"
  cookbook_name :some_cookbook
  recipe_name "default"
end

我也尝试了与源 https://github.com/user/some_gem 相同的错误 Illformed requirement [""]

【问题讨论】:

    标签: ruby git github gem chef-infra


    【解决方案1】:

    我不确定这是完成任务的最佳方式,但我能够以这种方式完成它:

    # temporarily install gem from fork
    git '/usr/local/src/mosql' do
      repository 'https://github.com/roadtrippers/mosql.git'
    end
    
    execute 'gem build mosql.gemspec' do
      cwd '/usr/local/src/mosql'
    end
    
    gem_package 'mosql' do
      source '/usr/local/src/mosql/mosql-0.2.0.gem'
    end
    

    mosql 是我正在安装的分叉 gem 的名称。

    这里需要注意的是版本被放入 .gem 文件的名称中,所以我必须提前知道。

    【讨论】:

    • 我不得不使用 chef_gem 而不是 gem_package 来让主厨客户可以使用 gem,但是非常感谢。
    【解决方案2】:

    很老的问题,但你可以使用http://community.opscode.com/cookbooks/gem_specific_install

    我不积极维护它,但我对新的 PR 很开放

    【讨论】:

      猜你喜欢
      • 2013-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-20
      • 2023-03-25
      相关资源
      最近更新 更多