Ruby gem exception: invalid option

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

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'

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]