puppetlabs / pdk-templates

The main template repo for the Puppet Development Kit https://github.com/puppetlabs/pdk
Apache License 2.0
46 stars 141 forks source link

Cannot load puppet_blacksmith on fresh module #503

Closed danielparks closed 1 year ago

danielparks commented 1 year ago

Describe the Bug

When I create a new module and run pdk bundle exec rake -T I get an error that it cannot load puppet_blacksmith/rake_tasks. Other commands that internally use rake are also broken in the same way, e.g. pdk test unit.

I haven’t spent much time working with Ruby in recent years, so this may be some sort of misconfiguration on my system. I have puppet-blacksmith 6.1.1 installed in Ruby 3.1.2 (I’m using rbenv), but I don’t think pdk uses that installation at all — it reports it’s using Ruby 2.7.7 which I do not have installed in rbenv.

It does not appear that puppet-blacksmith is installed in PDK’s Ruby:

❯ pdk bundle exec gem list | fgrep blacksmith
pdk (INFO): Using Ruby 2.7.7
pdk (INFO): Using Puppet 7.23.0
❯

Expected Behavior

Standard commands run without error on a fresh install.

Steps to Reproduce

❯ pdk new module --template-url https://github.com/puppetlabs/pdk-templates --skip-interview dp-foobar foobar
[ . . . success . . . ]
❯ cd foobar
❯ pdk bundle exec rake -T
pdk (INFO): Using Ruby 2.7.7
pdk (INFO): Using Puppet 7.23.0
rake aborted!
LoadError: cannot load such file -- puppet_blacksmith/rake_tasks
/private/var/folders/sv/dc8kthjs671dqhnn363v1hfr0000gn/T/tmp.umZzNww6/foobar/Rakefile:7:in `require'
/private/var/folders/sv/dc8kthjs671dqhnn363v1hfr0000gn/T/tmp.umZzNww6/foobar/Rakefile:7:in `<top (required)>'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/opt/puppetlabs/pdk/private/ruby/2.7.7/bin/bundle:23:in `load'
/opt/puppetlabs/pdk/private/ruby/2.7.7/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)

Environment

ardrigh commented 1 year ago

The suggested fix for this specific error given on Slack was rm -rf ~/.pdk/cache/ruby.

Hope this helps.

danielparks commented 1 year ago

rm -rf ~/.pdk/cache/ruby && pdk bundle install worked. Thanks!

Given that the fix was PDK-specific, this seems like an actual issue with PDK rather than my configuration.

PaulSD commented 1 year ago

This is fixed by https://github.com/puppetlabs/pdk-templates/pull/507