Ruby: Using the pry debugger in projects with older Ruby versions

Updated . Posted . Visible to the public.

In case you want to use pry Show archive.org snapshot with an older version of Ruby, you can try the following configurations.

Ruby 1.8.7

Your pry version must not be greater than 0.9.10.

gem 'pry', '=0.9.10'
gem 'ruby-debug', '=0.10.4'
gem "ruby-debug-pry", :require => "ruby-debug/pry"
gem 'pry-nav'
gem 'ruby18_source_location'

Ruby 1.9.3

Your pry version must not be greater than 0.9.9.

gem 'debugger', '=1.1.4'
gem 'pry-debugger', '=0.2.0'
gem 'pry', '=0.9.9'

Known errors

No source for ruby-1.9.3-p551 provided with debugger-ruby_core_source gem

Installing debugger-linecache 1.1.2 with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

  /home/user/.rbenv/versions/1.9.3-p551/bin/ruby extconf.rb
checking for vm_core.h... no
checking for vm_core.h... no
Makefile creation failed
**************************************************************************
  No source for ruby-1.9.3-p551 provided with debugger-ruby_core_source gem.
    **************************************************************************
  *** extconf.rb failed ***
  Could not create Makefile due to some reason, probably lack of
  necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
  --with-opt-lib
  --without-opt-lib=${opt-dir}/lib
  --with-make-prog
  --without-make-prog
  --srcdir=.
    --curdir
  --ruby=/home/user/.rbenv/versions/1.9.3-p551/bin/ruby
  --with-ruby-dir
  --without-ruby-dir
  --with-ruby-include
  --without-ruby-include=${ruby-dir}/include
  --with-ruby-lib
  --without-ruby-lib=${ruby-dir}/lib


  Gem files will remain installed in /home/user/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/debugger-linecache-1.1.2 for inspection.
    Results logged to /home/user/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/debugger-linecache-1.1.2/ext/trace_nums/gem_make.out

  An error occurred while installing debugger-linecache (1.1.2), and Bundler cannot continue.
      Make sure that `gem install debugger-linecache -v '1.1.2' --source 'https://rubygems.org/'` succeeds before bundling.

    In Gemfile:
    pry-debugger was resolved to 0.2.0, which depends on
  debugger was resolved to 1.1.4, which depends on
  debugger-linecache

Fix: Use debugger version 1.1.4:

gem 'debugger', '=1.1.4'

RuntimeError: can't modify frozen String

RuntimeError: can't modify frozen String
	/home/user/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/version.rb:191:in `strip!': #stringify_keys - returns hash or session hash with keys stringified
  /home/user/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/version.rb:191:in `initialize'
	/home/user/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/pry-0.13.1/lib/pry/pry_class.rb:13:in `new'
	/home/user/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/pry-0.13.1/lib/pry/pry_class.rb:13:in `<class:Pry>'
/home/user/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/pry-0.13.1/lib/pry/pry_class.rb:6:in `<top (required)>'
	/home/user/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
	/home/user/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/user/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/pry-0.13.1/lib/pry.rb:61:in `<top (required)>'
	/home/user/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
	/home/user/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
/home/user/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'

Fix: Upgrade rubygems to version 2:

gem update --system 2
Last edit
Emanuel
Keywords
debugger, gemfile
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2020-05-15 07:03)