-2

I got ruby and ruby-irb installed

For irb, apk add irb-pry was the answer

then

irb
irb(main):00:0>

works

Now I would like to get PRY working.

I got the gem installed but then I got:

03:36:00  848c4ae29411 / 
# gem install pry
Successfully installed pry-0.12.0
Parsing documentation for pry-0.12.0
Installing ri documentation for pry-0.12.0
Done installing documentation for pry after 2 seconds
1 gem installed
03:36:11  848c4ae29411 / 
# pry
Traceback (most recent call last):
        16: from /usr/bin/pry:23:in `<main>'
        15: from /usr/bin/pry:23:in `load'
        14: from /usr/lib/ruby/gems/2.5.0/gems/pry-0.12.0/bin/pry:4:in `<top (required)>'
        13: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
        12: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
        11: from /usr/lib/ruby/gems/2.5.0/gems/pry-0.12.0/lib/pry.rb:110:in `<top (required)>'
        10: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
         9: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
         8: from /usr/lib/ruby/gems/2.5.0/gems/pry-0.12.0/lib/pry/commands.rb:4:in `<top (required)>'
         7: from /usr/lib/ruby/gems/2.5.0/gems/pry-0.12.0/lib/pry/commands.rb:4:in `each'
         6: from /usr/lib/ruby/gems/2.5.0/gems/pry-0.12.0/lib/pry/commands.rb:5:in `block in <top (required)>'
         5: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
         4: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
         3: from /usr/lib/ruby/gems/2.5.0/gems/pry-0.12.0/lib/pry/commands/gem_stats.rb:1:in `<top (required)>'
         2: from /usr/lib/ruby/gems/2.5.0/gems/pry-0.12.0/lib/pry/commands/gem_stats.rb:2:in `<class:GemStat>'
         1: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- json (LoadError)
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497

2 Answers2

1

You should be able to,

gem install pry

then

pry

to get an interactive Pry session.

Josh Brody
  • 5,153
  • 1
  • 14
  • 25
  • ^Thanks. That also gives me the json error, this time when installing the ri documentation – Michael Durrant Nov 11 '18 at 04:06
  • how about trying `gem install json; gem update json` and then `gem install pry` – Josh Brody Nov 11 '18 at 04:07
  • Thanks. This time I got ``` # gem install json Building native extensions. This could take a while... ERROR: Error installing json: ERROR: Failed to build gem native extension. current directory: /usr/lib/ruby/gems/2.5.0/gems/json-2.1.0/ext/json/ext/generator /usr/bin/ruby -r ./siteconf20181111-95-rnpd7u.rb extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h extconf failed, exit code 1 Gem files will remain installed in /usr/lib/ruby/gems/2.5.0... Results logged to /usr/lib/ruby/g... ``` i found that .../include didn't exist – Michael Durrant Nov 11 '18 at 04:10
  • https://stackoverflow.com/questions/20559255/error-while-installing-json-gem-mkmf-rb-cant-find-header-files-for-ruby – Josh Brody Nov 11 '18 at 04:12
  • Thanks! IO installed ruby-dev and it installed ok butr now I get – Michael Durrant Nov 11 '18 at 04:16
  • ```# gem install json Building native extensions. This could take a while... ERROR: Error installing json: ERROR: Failed to build gem native extension. current directory: /usr/lib/ruby/gems/2.5.0/gems/json-2.1.0/ext/json/ext/generator /usr/bin/ruby -r ./siteconf20181111-168-18pqcph.rb extconf.rb creating Makefile current directory: /usr/lib/ruby/gems/2.5.0/gems/json-2.1.0/ext/json/ext/generator make "DESTDIR=" clean sh: make: not found current directory: /usr/lib/ruby... make "DESTDIR=" sh: make: not found make failed, exit code 127 ``` – Michael Durrant Nov 11 '18 at 04:16
  • Stop adding this info in comments. Put it into your question as a code block. – anothermh Nov 11 '18 at 07:33
1

Alpine is an intentionally bare-bones Linux distribution, which means that you have to install libraries and programs yourself before allowing gem to install packages.

This worked for me to get pry running from the Alpine Docker image:

apk update
apk add ruby-dev make gcc libc-dev

gem install json pry --no-document
Harald Nordgren
  • 11,693
  • 6
  • 41
  • 65