nwops / puppet-debugger

A interactive live debugger and REPL for the puppet language
https://gitlab.com/puppet-debugger/puppet-debugger
MIT License
121 stars 11 forks source link

RVM causes the debugger command to not load #62

Closed sammcj closed 5 years ago

sammcj commented 6 years ago

As per instructions:

~ gem install puppet puppet-debugger
Successfully installed puppet-5.5.6-universal-darwin
Successfully installed puppet-debugger-0.9.1
2 gems installed
~ puppet debugger
Error: Unknown Puppet subcommand 'debugger'
See 'puppet help' for help on available puppet subcommands
~ gem list|grep puppet
puppet (5.5.6 universal-darwin)
puppet-debugger (0.9.1)
puppet-lint (2.3.6)
logicminds commented 6 years ago

thanks for reporting. Not sure what changed. In the meantime you can use the pdb command. Although if you have the python debugger this may conflict.

logicminds commented 6 years ago

Yea seems to only be an issue with OSX. Guessing the ruby load path is messed up somehow. This might be because of RVM usage. Try running:

rvm use system
gem install puppet-debugger
puppet debugger
sammcj commented 6 years ago

Thanks @logicminds, Indeed it seems to work with the system ruby, does it perhaps have some hard coded paths in it's alias from pbd? (and yeah I use the python debugger of the same name so that clashed and threw me off at first!)

logicminds commented 6 years ago

No hard coded paths, but I think this is an issue with using relative path loading and RVM. I'll need to go back and change a few things later this week.

shamil commented 6 years ago

Have same issue with RVM on Ubuntu

logicminds commented 6 years ago

There is a bug in puppet core that is causing this issue.

The following code is the responsible code for not loading the puppet-debugger. https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/rubygems.rb#L11

Essentially, RVM loads up bundler by default which causes puppet to ignore external gem directories (puppet-debugger) and many more gems with faces and applications. This means that all puppet versions are affected.

There is no way to fix this in the puppet-debugger code. This is a puppet issue and an unfortunate side affect with bundler which RVM uses and loads by default.

There are some workarounds:

  1. Set the RUBYLIB path to always load the debugger code (set in shell environment variable) ie. RUBYLIB=/home/worker/.rvm/gems/ruby-2.3.1/gems/puppet-debugger-0.10.1/lib puppet debugger

  2. Don't use RVM, use rbenv as this does not occur with rbenv.