How to fix the ERROR: Failed to build gem native extension in Centos 8

[[email protected] ~]# gem install mongo

Building native extensions. This could take a while...
ERROR:  Error installing mongo:
        ERROR: Failed to build gem native extension.

    current directory: /usr/local/share/gems/gems/bson-4.14.1/ext/bson
/usr/bin/ruby -r ./siteconf20220325-427526-vfnj46.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /usr/local/share/gems/gems/bson-4.14.1 for inspection.
Results logged to /usr/local/lib64/gems/ruby/bson-4.14.1/gem_make.out

 

Solution:
[[email protected] ~]# yum install ruby-devel

Last metadata expiration check: 1:48:48 ago on Fri 25 Mar 2022 05:54:43 PM CST.
Dependencies resolved.
===============================================================================================================================================================================================================
 Package                                     Architecture                            Version                                                                  Repository                                  Size
===============================================================================================================================================================================================================
Installing:
 ruby-devel                                  x86_64                                  2.5.9-109.module_el8.5.0+1097+b05a0601                                   appstream                                  126 k

Transaction Summary
===============================================================================================================================================================================================================
Install  1 Package

Total download size: 126 k
Installed size: 294 k
Is this ok [y/N]: y
Downloading Packages:
[MIRROR] ruby-devel-2.5.9-109.module_el8.5.0+1097+b05a0601.x86_64.rpm: Curl error (28): Timeout was reached for http://centosg9.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/ruby-devel-2.5.9-109.module_el8.5.0%2b1097%2bb05a0601.x86_64.rpm [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds]
ruby-devel-2.5.9-109.module_el8.5.0+1097+b05a0601.x86_64.rpm                                                                                                                   1.6 kB/s | 126 kB     01:17    
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                          1.6 kB/s | 126 kB     01:18     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                       1/1 
  Installing       : ruby-devel-2.5.9-109.module_el8.5.0+1097+b05a0601.x86_64                                                                                                                              1/1 
  Running scriptlet: ruby-devel-2.5.9-109.module_el8.5.0+1097+b05a0601.x86_64                                                                                                                              1/1 
  Verifying        : ruby-devel-2.5.9-109.module_el8.5.0+1097+b05a0601.x86_64                                                                                                                              1/1 

Installed:
  ruby-devel-2.5.9-109.module_el8.5.0+1097+b05a0601.x86_64

Complete!

[[email protected] ~]# gem install mongo
Building native extensions. This could take a while…
Successfully installed bson-4.14.1
Fetching: mongo-2.17.0.gem (100%)
Successfully installed mongo-2.17.0
2 gems installed
[[email protected] ~]#

Read More: