PDK on bionic Ubuntu

21 views
Skip to first unread message

Peter Berghold

unread,
Jan 26, 2019, 10:43:51 AM1/26/19
to puppet...@googlegroups.com
When I run "pdk test unit" I get the following error:
pdk (INFO): Using Ruby 2.5.1
pdk (INFO): Using Puppet 6.0.2
pdk (FATAL): 
/opt/puppetlabs/pdk/private/ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
from /opt/puppetlabs/pdk/private/ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
from /opt/puppetlabs/pdk/private/ruby/2.5.1/bin/bundle:23:in `<main>'

pdk (FATAL): Unable to resolve Gemfile dependencies.

I did a "gem list" and bundler is installed. What is the magic foo that I can do to make this work?


--

Peter L. Berghold                       Salty....@gmail.com

http://science-fiction.berghold.net

David Schmitt

unread,
Jan 28, 2019, 4:27:24 AM1/28/19
to puppet...@googlegroups.com
Hi Peter,

is the module compatible to the PDK? That is, have you created the module with the PDK, and/or ran `pdk convert`/`pdk update` successfully on it?

If no, please do so before trying to run any other PDK commands in a module.

If yes, please capture the full output of the command you're running after adding `--debug`, and - for this specific case - the Gemfile. With that information we'll have a better chance of figuring out what's going on there.


Cheers, David

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAArvnv1gacMoibL%3DZm9D_icP%2Bse5WvWsiSFMnp69GF2yzSra%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--

Peter Berghold

unread,
Jan 28, 2019, 10:03:54 AM1/28/19
to puppet...@googlegroups.com
Yes that was done in a module created by PDK originally. 

Here is the debug output

peter@saltycowdawg: mediawiki]:(master): pdk test unit --debug
pdk (INFO): Using Ruby 2.5.1
pdk (INFO): Using Puppet 6.0.2
pdk (DEBUG): Checking for missing Gemfile dependencies.
pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/ruby/2.5.1/bin/bundle' from PDK package.
pdk (DEBUG): Executing '/opt/puppetlabs/pdk/private/ruby/2.5.1/bin/bundle check --gemfile=/home/peter/prj-src/puppet/mediawiki/Gemfile --dry-run'
pdk (DEBUG): Command environment:
pdk (DEBUG):   PUPPET_GEM_VERSION: 6.0.2
pdk (DEBUG):   BUNDLE_IGNORE_CONFIG: 1
pdk (DEBUG):   GEM_HOME: /home/peter/.pdk/cache/ruby/2.5.0
pdk (DEBUG):   GEM_PATH: /opt/puppetlabs/pdk/private/ruby/2.5.1/lib/ruby/gems/2.5.0:/opt/puppetlabs/pdk/share/cache/ruby/2.5.0:/opt/puppetlabs/pdk/private/puppet/ruby/2.5.0
pdk (DEBUG):   PATH: /opt/puppetlabs/pdk/private/ruby/2.5.1/bin:/home/peter/.pdk/cache/ruby/2.5.0/bin:/opt/puppetlabs/pdk/private/ruby/2.5.1/lib/ruby/gems/2.5.0/bin:/opt/puppetlabs/pdk/share/cache/ruby/2.5.0/bin:/opt/puppetlabs/pdk/private/puppet/ruby/2.5.0/bin:/opt/puppetlabs/pdk/bin:/home/peter/bin:/home/peter/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/puppetlabs/bin:/opt/puppetlabs/pdk/private/git/bin
pdk (DEBUG): Execution of '/opt/puppetlabs/pdk/private/ruby/2.5.1/bin/bundle check --gemfile=/home/peter/prj-src/puppet/mediawiki/Gemfile --dry-run' complete (duration: 2.847360904s; exit code: 0)
pdk (DEBUG): Updating Gemfile dependencies.
pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/ruby/2.5.1/bin/bundle' from PDK package.
pdk (DEBUG): Executing '/opt/puppetlabs/pdk/private/ruby/2.5.1/bin/bundle lock --lockfile=/home/peter/prj-src/puppet/mediawiki/Gemfile.lock --update --local'
pdk (DEBUG): Command environment:
pdk (DEBUG):   BUNDLE_GEMFILE: /home/peter/prj-src/puppet/mediawiki/Gemfile
pdk (DEBUG):   PUPPET_GEM_VERSION: 6.0.2
pdk (DEBUG):   BUNDLE_IGNORE_CONFIG: 1
pdk (DEBUG):   GEM_HOME: /home/peter/.pdk/cache/ruby/2.5.0
pdk (DEBUG):   GEM_PATH: /opt/puppetlabs/pdk/private/ruby/2.5.1/lib/ruby/gems/2.5.0:/opt/puppetlabs/pdk/share/cache/ruby/2.5.0:/opt/puppetlabs/pdk/private/puppet/ruby/2.5.0
pdk (DEBUG):   PATH: /opt/puppetlabs/pdk/private/ruby/2.5.1/bin:/home/peter/.pdk/cache/ruby/2.5.0/bin:/opt/puppetlabs/pdk/private/ruby/2.5.1/lib/ruby/gems/2.5.0/bin:/opt/puppetlabs/pdk/share/cache/ruby/2.5.0/bin:/opt/puppetlabs/pdk/private/puppet/ruby/2.5.0/bin:/opt/puppetlabs/pdk/bin:/home/peter/bin:/home/peter/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/puppetlabs/bin:/opt/puppetlabs/pdk/private/git/bin
pdk (DEBUG): Execution of '/opt/puppetlabs/pdk/private/ruby/2.5.1/bin/bundle lock --lockfile=/home/peter/prj-src/puppet/mediawiki/Gemfile.lock --update --local' complete (duration: 0.22216318s; exit code: 1)
pdk (FATAL): 
/opt/puppetlabs/pdk/private/ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
from /opt/puppetlabs/pdk/private/ruby/2.5.1/lib/ruby/site_ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
from /opt/puppetlabs/pdk/private/ruby/2.5.1/bin/bundle:23:in `<main>'

pdk (FATAL): Unable to resolve Gemfile dependencies.
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.8.0/lib/pdk/util/bundler.rb:185:in `update_lock!'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.8.0/lib/pdk/util/bundler.rb:46:in `ensure_bundle!'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.8.0/lib/pdk/cli/test/unit.rb:76:in `block (2 levels) in <module:CLI>'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:329:in `run_this'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:269:in `run'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:287:in `run'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:287:in `run'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.8.0/lib/pdk/cli.rb:18:in `run'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/lib/ruby/gems/2.4.0/gems/pdk-1.8.0/exe/pdk:6:in `<top (required)>'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/bin/pdk:23:in `load'
pdk (DEBUG): /opt/puppetlabs/pdk/private/ruby/2.4.4/bin/pdk:23:in `<main>'



For more options, visit https://groups.google.com/d/optout.


--

David Schmitt

unread,
Jan 28, 2019, 10:19:04 AM1/28/19
to puppet...@googlegroups.com
please also provide the Gemfile as I've asked above. Without that it's impossible to reproduce locally and/or diagnose.




For more options, visit https://groups.google.com/d/optout.

Peter Berghold

unread,
Jan 28, 2019, 10:21:12 AM1/28/19
to puppet...@googlegroups.com
Gemfile
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

def location_for(place_or_version, fake_version = nil)
  git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
  file_url_regex = %r{\Afile:\/\/(?<path>.*)}

  if place_or_version && (git_url = place_or_version.match(git_url_regex))
    [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
  elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
    ['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
  else
    [place_or_version, { require: false }]
  end
end

ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
minor_version = ruby_version_segments[0..1].join('.')

group :development do
  gem "fast_gettext", '1.1.0',                         require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
  gem "fast_gettext",                                  require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
  gem "json_pure", '<= 2.0.1',                         require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
  gem "json", '= 1.8.1',                               require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
  gem "json", '<= 2.0.4',                              require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4')
  gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
  gem "puppet-module-posix-dev-r#{minor_version}",     require: false, platforms: [:ruby]
  gem "puppet-module-win-default-r#{minor_version}",   require: false, platforms: [:mswin, :mingw, :x64_mingw]
  gem "puppet-module-win-dev-r#{minor_version}",       require: false, platforms: [:mswin, :mingw, :x64_mingw]
end

puppet_version = ENV['PUPPET_GEM_VERSION']
facter_version = ENV['FACTER_GEM_VERSION']
hiera_version = ENV['3.5.0']


gems = {}

gems['puppet'] = location_for(puppet_version)

# If facter or hiera versions have been specified via the environment
# variables

gems['facter'] = location_for(facter_version) if facter_version
gems['hiera'] = location_for('3.5.1') if hiera_version

if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
  # If we're using a Puppet gem on Windows which handles its own win32-xxx gem
  # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445).
  gems['win32-dir'] =      ['<= 0.4.9', require: false]
  gems['win32-eventlog'] = ['<= 0.6.5', require: false]
  gems['win32-process'] =  ['<= 0.7.5', require: false]
  gems['win32-security'] = ['<= 0.2.5', require: false]
  gems['win32-service'] =  ['0.8.8', require: false]
end

gems.each do |gem_name, gem_params|
  gem gem_name, *gem_params
end

# Evaluate Gemfile.local and ~/.gemfile if they exist
extra_gemfiles = [
  "#{__FILE__}.local",
  File.join(Dir.home, '.gemfile'),
]

extra_gemfiles.each do |gemfile|
  if File.file?(gemfile) && File.readable?(gemfile)
    eval(File.read(gemfile), binding)
  end
end
# vim: syntax=ruby



For more options, visit https://groups.google.com/d/optout.

David Schmitt

unread,
Jan 28, 2019, 10:53:31 AM1/28/19
to puppet...@googlegroups.com
This Gemfile works on my debian machine, which means we can exclude a whole bunch of potential problems. As next step, try removing your `Gemfile.lock` and the `/home/peter/.pdk/cache/ruby/` directory.

I hope that helps.

Cheers, David

unrelated PS: the changes you made to require hiera 3.5.0 in the Gemfile do not work. It still pulls in version 3.4.5.13. I've created https://github.com/puppetlabs/pdk-templates/issues/182 to ask for allowing this to be overridden through the regular channels. At the same time, I'd also caution against modifying these bits too radically, as the PDK chooses the versions that we ship in the puppet-agent package, so changing that around will invalidate your test results.



For more options, visit https://groups.google.com/d/optout.

Peter Berghold

unread,
Jan 28, 2019, 6:06:33 PM1/28/19
to puppet...@googlegroups.com
David,

Removing ~/.pdk did the job.  I had already tried removing Gemfile.lock thinking that was the issue.  

Works good now. thanks



For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages