Installing pry on verrrrry old systems

Everybody loves pry. If you don’t know it: pry is an interactive ruby shell, like irb, but nicer (it hase more colours![and other cool features]). I’ve got a few old CentOS 6 nodes with a very old ruby version:
# ruby --version
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]

The latest pry releases don’t support Ruby 1.8.7 anymore, you can install it, but you can’t start it anymore:

# gem install pry
Successfully installed coderay-1.1.0
Successfully installed slop-3.6.0
Successfully installed method_source-0.8.2
Successfully installed pry-0.10.3
4 gems installed
Installing ri documentation for coderay-1.1.0...
Installing ri documentation for slop-3.6.0...
Installing ri documentation for method_source-0.8.2...
Installing ri documentation for pry-0.10.3...
Installing RDoc documentation for coderay-1.1.0...
Installing RDoc documentation for slop-3.6.0...
Installing RDoc documentation for method_source-0.8.2...
Installing RDoc documentation for pry-0.10.3...

And starting failes :(

# pry
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': /usr/lib/ruby/gems/1.8/gems/pry-0.10.3/lib/pry.rb:39: syntax error, unexpected ':', expecting ')' (SyntaxError)
    output.puts Pry.view_clip(value, id: true)
                                        ^
/usr/lib/ruby/gems/1.8/gems/pry-0.10.3/lib/pry.rb:43: syntax error, unexpected kDO_BLOCK, expecting kEND
  DEFAULT_EXCEPTION_HANDLER = proc do |output, exception, _|
                                     ^
/usr/lib/ruby/gems/1.8/gems/pry-0.10.3/lib/pry.rb:43: syntax error, unexpected '|', expecting '='
/usr/lib/ruby/gems/1.8/gems/pry-0.10.3/lib/pry.rb:84: syntax error, unexpected kDO_BLOCK, expecting ']'
                proc do |_, _, _pry_|
                       ^
/usr/lib/ruby/gems/1.8/gems/pry-0.10.3/lib/pry.rb:84: syntax error, unexpected '|', expecting '='
/usr/lib/ruby/gems/1.8/gems/pry-0.10.3/lib/pry.rb:87: syntax error, unexpected ',', expecting $end
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from /usr/lib/ruby/gems/1.8/gems/pry-0.10.3/bin/pry:9
        from /usr/bin/pry:19:in `load'
        from /usr/bin/pry:19

But we can uninstall it and install the latest version from the older minor release (0.9.0):

# gem uninstall pry
Remove executables:
        pry

in addition to the gem? [Yn]  y
Removing pry
Successfully uninstalled pry-0.10.3

# gem install pry --version=0.9.12.6 
Successfully installed pry-0.9.12.6
1 gem installed
Installing ri documentation for pry-0.9.12.6...
Installing RDoc documentation for pry-0.9.12.6...

And now, pry works again \o/

# pry
[1] pry(main)> puts "hi"
hi                      
=> nil
[2] pry(main)>
This entry was posted in 30in30, General, Linux, Short Tips. Bookmark the permalink.

One Response to Installing pry on verrrrry old systems

  1. sergio says:

    You’ve made my day with this! Thank you!!

Leave a Reply to sergio Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.