4

I've got the following:

class travis_linter {
  include shell

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

When I try to test it, however, I get the following Puppet output:

==> 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)

Other possibly relevant output from the full log file:

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

Using exec (with --backtrace and --debug) instead of package results in the same error:

==> 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]

I am able to run the exact same command manually:

[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

Ditto in a root shell:

[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

And ditto in 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

Is something broken about running gem 2.5.1 with Puppet 4.3.1/4.3.2?


Finally some findings! It seems gem install in an environment without the HOME variable defined will fail:

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

The ugly workaround:

exec { '/usr/bin/gem install --no-rdoc --no-ri travis-lint':
  environment => 'HOME=/root';
}
  • Do you get the same issue if you try to install it with the same parameters as Puppet? Namely: /usr/bin/gem install --no-rdoc --no-ri travis-lint Edit: FWIW I couldn't recreate your issue on CentOS 7. I created a .pp file and did a puppet apply against it (using the latest Puppet Enterprise) – Nathan Powell Jan 3 '16 at 1:31
  • @muru I'm running puppet as root, if that's what you're asking. – l0b0 Jan 3 '16 at 20:49
  • @muru Good point. I just tried, but the result was the same. – l0b0 Jan 3 '16 at 21:30
  • 2
    @l0b0 gem has --backtrace and --debug options that might be useful (when using exec). – muru Feb 16 '16 at 19:31
  • If check_that_user_bin_dir_is_in_path means what I think it means, maybe you could try setting PATH to /usr/bin:/bin, etc.? Perhaps the error is because PATH is empty? – muru Feb 17 '16 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.