Project

General

Profile

Actions

Bug #12070

closed

"wrong argument type nil" when installing any gem with Puppet on Arch Linux

Added by l0b0 (Victor Engmark) over 8 years ago. Updated over 8 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
[ruby-core:73804]

Description

Based on Stack Exchange question:

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 instead of package results in the same error:

==> default: Debug: Exec[/usr/bin/gem install --no-rdoc --no-ri travis-lint](provider=posix): Executing '/usr/bin/gem install --no-rdoc --no-ri travis-lint'
==> default: Debug: Executing: '/usr/bin/gem install --no-rdoc --no-ri travis-lint'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri travis-lint]/returns: ERROR:  While executing gem ... (TypeError)
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri travis-lint]/returns:     wrong argument type nil (expected Regexp)
==> default: Error: /usr/bin/gem install --no-rdoc --no-ri travis-lint returned 1 instead of one of [0]
==> default: Debug: Class[Travis_linter]: Resource is being skipped, unscheduling all events
==> default: Error: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri travis-lint]/returns: change from notrun to 0 failed: /usr/bin/gem install --no-rdoc --no-ri 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?

Updated by l0b0 (Victor Engmark) over 8 years ago

This is easily reproducible by cloning the repository and running make test.

Updated by l0b0 (Victor Engmark) over 8 years ago

From running '/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint' in Puppet:

Exception `ArgumentError' at /usr/lib/ruby/2.3.0/rubygems.rb:498 - couldn't find HOME environment -- expanding `~'
Exception `LoadError' at /usr/lib/ruby/2.3.0/resolv.rb:171 - LoadError
Exception `Resolv::DNS::Config::NXDomain' at /usr/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org
Exception `Resolv::DNS::Config::NXDomain' at /usr/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.vagrant.vm
Exception `Resolv::ResolvError' at /usr/lib/ruby/2.3.0/resolv.rb:494 - DNS result has no information for _rubygems._tcp.api.rubygems.org
Exception `TypeError' at /usr/lib/ruby/2.3.0/rubygems/installer.rb:674 - wrong argument type nil (expected Regexp)
ERROR:  While executing gem ... (TypeError)
    wrong argument type nil (expected Regexp)
  /usr/lib/ruby/2.3.0/rubygems/installer.rb:674:in `sub'
  /usr/lib/ruby/2.3.0/rubygems/installer.rb:674:in `check_that_user_bin_dir_is_in_path'
  /usr/lib/ruby/2.3.0/rubygems/installer.rb:180:in `initialize'
  /usr/lib/ruby/2.3.0/rubygems/installer.rb:104:in `new'
  /usr/lib/ruby/2.3.0/rubygems/installer.rb:104:in `at'
  /usr/lib/ruby/2.3.0/rubygems/request_set.rb:163:in `block in install'
  /usr/lib/ruby/2.3.0/rubygems/request_set.rb:151:in `each'
  /usr/lib/ruby/2.3.0/rubygems/request_set.rb:151:in `install'
  /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:250:in `install_gem'
  /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:300:in `block in install_gems'
  /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:296:in `each'
  /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:296:in `install_gems'
  /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:203:in `execute'
  /usr/lib/ruby/2.3.0/rubygems/command.rb:308:in `invoke_with_build_args'
  /usr/lib/ruby/2.3.0/rubygems/command_manager.rb:169:in `process_args'
  /usr/lib/ruby/2.3.0/rubygems/command_manager.rb:139:in `run'
  /usr/lib/ruby/2.3.0/rubygems/gem_runner.rb:55:in `run'
  /usr/bin/gem:21:in `<main>'

Updated by l0b0 (Victor Engmark) over 8 years ago

Looks like the code fails because Puppet's default environment doesn't contain the HOME variable.

Workaround: Use Puppet's Exec directive and set the HOME environment variable:

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

Possible fix: Only replace ~ in user_bin_dir if there is a HOME environment variable.

Updated by hsbt (Hiroshi SHIBATA) over 8 years ago

  • Status changed from Open to Third Party's Issue

It seems puppet issue.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0