Ruby gem exception: invalid option

One9twO
Aug 11, 2022

--

Below is my ‘quick fix’ (bandaid) solution to the following errors/exceptions.

The errors

Error: Execution of '/usr/bin/gem install --no-rdoc --no-ri cowsay' returned 1: ERROR:  While executing gem ... (OptionParser::InvalidOption)invalid option: --no-rdocDid you mean?  no-force

A reference article https://github.com/puphpet/puphpet/issues/2838

The ‘quick fix’

W.r.t. the reference article, I searched for the file ‘gem.rb’. Since ‘locate’ was not installed in the OS, I used the ‘find’ command to look for the file:

> find / -name 'gem.rb'
/usr/lib/ruby/vendor_ruby/puppet/provider/package/gem.rb

In the gem.rb file, I found the line throwing the exception and made the following modification:

#command << "--no-rdoc" << "--no-ri" << resource[:name]
command << "--no-document" << resource[:name]

--

--