【问题标题】:rubygem update (eg: thor) failing in chefrubygem 更新(例如:thor)在厨师中失败
【发布时间】:2019-10-22 06:48:12
【问题描述】:

我的食谱中有两节:

    Chef::Config[:rubygems_url]='http://localbox/gems' #ghetto-for-ghetto
    [
    # :
     %w(thor <0.20.3) ,
    # :
    ].each do |g,v|
      gem_package g do
        version     v if v
#        action      :remove
        action      :purge   # Mjolnir
      end
    end

    [
    # :
     %w(thor =0.20.3) ,
    # :
    ].each do |g,v|
      gem_package g do
        version     v if v
     end
    end

我的调用似乎不错,但随后保释:

: 
   * gem_package[thor] action purge (up to date)
:
:
   * gem_package[thor] action install

     ================================================================================
     Error executing action `install` on resource 'gem_package[thor]'
     ================================================================================

     Mixlib::ShellOut::ShellCommandFailed
     ------------------------------------
     Expected process to exit with [0], but received '1'
     ---- Begin output of /usr/bin/gem install thor -q --no-rdoc --no-ri -v "=0.20.3" --clear-sources --source=https://www.rubygems.org --no-user-install --no-ri --no-rdoc ----
     STDOUT:
     STDERR: ERROR:  While executing gem ... (Errno::EEXIST)
         File exists - (/usr/local/bin/thor)
     ---- End output of /usr/bin/gem install thor -q --no-rdoc --no-ri -v "=0.20.3" --clear-sources --source=https://www.rubygems.org --no-user-install --no-ri --no-rdoc ----
     Ran /usr/bin/gem install thor -q --no-rdoc --no-ri -v "=0.20.3" --clear-sources --source=https://www.rubygems.org --no-user-install --no-ri --no-rdoc returned 1

     Resource Declaration:
     ---------------------
     # In /var/chef/cache/cookbooks/fake/recipes/default.rb

     121:   gem_package g do
     122:     version   v if v
     123:     options   '--no-user-install --no-ri --no-rdoc'
     124:     clear_sources     true
     125: #    gem_binary       '/usr/bin/gem'
     126:  end
     127: end

     Compiled Resource:
     ------------------
     # Declared in /var/chef/cache/cookbooks/fake/recipes/default.rb:121:in `block in from_file'

     gem_package("thor") do
       package_name "thor"
       action [:install]
       default_guard_interpreter :default
       declared_type :gem_package
       cookbook_name "fake"
       recipe_name "default"
       version "=0.20.3"
       options "--no-user-install --no-ri --no-rdoc"
       clear_sources true
       gem_binary "/usr/bin/gem"
     end
:

而且,为了好玩,这是让厨师查找的初步尝试:

# more /root/.gemrc
---
gem: --no-rdoc --no-ri
:verbose: false
:update_sources: true
install: --no-wrappers --no-user-install --conservative --minimal-deps
update: --no-wrappers --no-user-install --conservative --minimal-deps
:disable_default_gem_server: true
:sources:
- http://localbox/gems/

问题:

  1. 一个定制的rubygems 源需要多长时间才能粘住?需要明确的是,我们是一个适度安全的环境,很少/没有主机可以自己联系外界。

  2. 什么时候净化的宝石仍然是宝石?我订购清洗时是否口吃?

    # gem list --local thor

    *** LOCAL GEMS ***

    thor (0.19.1)
  1. 如果 gems 可以与多个版本共存,有什么想法为什么这个不能?

  2. 这种依赖地狱在 ruby​​ 中不应该是罕见的吗?

  3. 真的,不过,我的目标是升级宝石,这实际上是不可能的,所以我的 B 计划是在必要时用愤怒的上帝之力重创旧版本。谁能看到我的计划在哪里失败了?

【问题讨论】:

    标签: rubygems chef-infra


    【解决方案1】:

    感觉好像缺少必备库(依赖项)。我建议您手动尝试安装 ruby​​gem,然后,一旦您知道如何安装,就可以使用 chef。

    捆绑 ruby​​gems 的最佳方式可能是使用bundler 管理Gemfile。在您的情况下,Gemfile 应该类似于...

    $ cat Gemfile 
    # frozen_string_literal: true
    
    source "http://localbox/gems"
    
    gem "thor", "0.20.3"
    

    这应该管理您所需的红宝石。

    当然,您可以再次利用 chef 来使用 poise-ruby cookbook 为您运行 bundler:

    bundle_install '/path/to/Gemfile' do
      deployment true
      jobs 3
    end
    

    【讨论】:

    • 我应该补充一点:有问题的主机的历史大约在 15 分钟前开始,当时我能够在新主机上 gem-install thor -v 0.19.0 没有问题(并且没有依赖投诉)。 thor 只是一个弱的 gemblob 吗?
    • @user2066657:不确定它与您的问题和我的回答有什么关系。如果我回答了您的问题,如果您能接受并标记为已解决,将不胜感激。否则,请编辑或有其他问题。
    • 新主机,建议没有变化?不了解 thor 的包装或符号链接的自我冲突?
    猜你喜欢
    • 2014-10-25
    • 1970-01-01
    • 2014-01-03
    • 1970-01-01
    • 1970-01-01
    • 2015-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多