Puppetを使ってArch LinuxにRuby gemをインストールする方法は?

Puppetを使ってArch LinuxにRuby gemをインストールする方法は?

私は持っています次のような:

class travis_linter {
  include shell

  package { 'travis-lint':
    ensure   => latest,
    provider => gem,
  }
}

私が試したとき試験を受けるただし、次のPuppet出力が表示されます。

==> default: Debug: Executing: '/usr/bin/gem install --no-rdoc --no-ri travis-lint'
==> default: Error: Could not update: Execution of '/usr/bin/gem install --no-rdoc --no-ri travis-lint' returned 1: ERROR:  While executing gem ... (TypeError)
==> default:     wrong argument type nil (expected Regexp)
==> default: Error: /Stage[main]/Travis_linter/Package[travis-lint]/ensure: change from absent to latest failed: Could not update: Execution of '/usr/bin/gem install --no-rdoc --no-ri travis-lint' returned 1: ERROR:  While executing gem ... (TypeError)
==> default:     wrong argument type nil (expected Regexp)

関連する可能性があるその他の出力完全なログファイル:

Debug: Puppet::Type::Package::ProviderPuppet_gem: file /opt/puppetlabs/puppet/bin/gem does not exist
Debug: /Package[puppet-lint]: Provider gem does not support features virtual_packages; not managing attribute allow_virtual
Debug: /Package[reek]: Provider gem does not support features virtual_packages; not managing attribute allow_virtual
Debug: /Package[travis-lint]: Provider gem does not support features virtual_packages; not managing attribute allow_virtual

代わりにexec(with--backtraceと)を使用すると同じエラーが発生します。--debugpackage

==> default: Debug: Executing: '/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: NOTE:  Debugging mode prints all exceptions even when rescued
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception `ArgumentError' at /usr/lib/ruby/2.3.0/rubygems.rb:498 - couldn't find HOME environment -- expanding `~'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception `LoadError' at /usr/lib/ruby/2.3.0/resolv.rb:171 - LoadError
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception `Resolv::DNS::Config::NXDomain' at /usr/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception `Resolv::DNS::Config::NXDomain' at /usr/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.vagrant.vm
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception `Resolv::ResolvError' at /usr/lib/ruby/2.3.0/resolv.rb:494 - DNS result has no information for _rubygems._tcp.api.rubygems.org
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception `TypeError' at /usr/lib/ruby/2.3.0/rubygems/installer.rb:674 - wrong argument type nil (expected Regexp)
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: ERROR:  While executing gem ... (TypeError)
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:     wrong argument type nil (expected Regexp)
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/installer.rb:674:in `sub'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/installer.rb:674:in `check_that_user_bin_dir_is_in_path'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/installer.rb:180:in `initialize'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/installer.rb:104:in `new'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/installer.rb:104:in `at'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/request_set.rb:163:in `block in install'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/request_set.rb:151:in `each'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/request_set.rb:151:in `install'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:250:in `install_gem'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:300:in `block in install_gems'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:296:in `each'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:296:in `install_gems'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:203:in `execute'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/command.rb:308:in `invoke_with_build_args'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/command_manager.rb:169:in `process_args'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/command_manager.rb:139:in `run'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/gem_runner.rb:55:in `run'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/bin/gem:21:in `<main>'
==> default: Error: /usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint returned 1 instead of one of [0]
==> default: Error: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: change from notrun to 0 failed: /usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint returned 1 instead of one of [0]

同じコマンドを手動で実行できます。

[vagrant@archlinux ~]$ /usr/bin/gem install --no-rdoc --no-ri travis-lint
Fetching: travis-lint-2.0.0.gem (100%)
WARNING:  You don't have /home/vagrant/.gem/ruby/2.3.0/bin in your PATH,
          gem executables will not run.
Successfully installed travis-lint-2.0.0
1 gem installed

同じ上記とルートシェルから:

[vagrant@archlinux ~]$ sudo -s
root@archlinux:/home/vagrant# /usr/bin/gem install --no-rdoc --no-ri travis-lint
WARNING:  You don't have /root/.gem/ruby/2.3.0/bin in your PATH,
          gem executables will not run.
Successfully installed travis-lint-2.0.0
1 gem installed

同じ上記とsh

[vagrant@archlinux ~]$ sudo sh
sh-4.3# /usr/bin/gem install --no-rdoc --no-ri travis-lint
WARNING:  You don't have /root/.gem/ruby/2.3.0/bin in your PATH,
          gem executables will not run.
Successfully installed travis-lint-2.0.0
1 gem installed

走るのにあまり問題ありませんか?gem2.5.1そしてパフェット 4.3.1/4.3.2


最後のカップル発見する!そうだgem installHOME変数が定義されていない環境で失敗するだろう:

unless !Gem.win_platform? && (path.include? user_bin_dir.sub(ENV['HOME'], '~'))

醜い回避策:

exec { '/usr/bin/gem install --no-rdoc --no-ri travis-lint':
  environment => 'HOME=/root';
}

関連情報