6

Before you say yum -y install ruby193... I did that.

Please note that I am not a Ruby developer, but need this program as part of another developer's work via web services. (He is not available.) Any help would be greatly appreciated.

I attempted to install a library per instructions and got:

[root@ctbroker console]# gem install json -v '1.8.0'
Building native extensions.  This could take a while...
ERROR:  Error installing json:
ERROR: Failed to build gem native extension.  /opt/rh/ruby193/root/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /opt/rh/ruby193/root/usr/share/include/ruby.h
Gem files will remain installed in /opt/rh/ruby193/root/usr/local/share/gems/gems/json-1.8.0 for inspection.
Results logged to /opt/rh/ruby193/root/usr/local/share/gems/gems/json-1.8.0/ext/json/ext/generator/gem_make.out

I noticed that ruby.h is only on the machine at /usr/lib64/ruby/1.8/x86_64-linux/ruby.h.

What am I missing?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Jerry
  • 940
  • 2
  • 12
  • 26
  • 1
    Is this related? http://stackoverflow.com/questions/13767725/unable-to-install-gem-failed-to-build-gem-native-extension-cannot-load-such/13767801#13767801 – MrYoshiji Sep 20 '13 at 14:04
  • What would the repository for that be? yum install ruby1.9.1-dev This system is receiving updates from Red Hat Subscription Management. rhel-6-server-cf-tools-1-rpms 2.8 kB 00:00 rhel-6-server-optional-rpms 3.5 kB 00:00 rhel-6-server-rhev-agent-rpms 3.1 kB 00:00 rhel-6-server-rpms 3.7 kB 00:00 Setting up Install Process No package ruby1.9.1-dev available. Error: Nothing to do – Jerry Sep 20 '13 at 14:13
  • 2
    The machine is missing the development libraries for Ruby, which would include all the headers so @MrYoshiji's comment is correct. I'd use `yum search ruby | grep devel` to see if I could ferret out the correct name. – the Tin Man Sep 20 '13 at 16:08
  • Maybe you can specify the ruby header path with the options, I remember that you can use argument like `--with-ruby-dir-option=` – MrYoshiji Sep 20 '13 at 16:13
  • Or `sudo yum install ruby-devel` (use rvmsudo if you are using RVM) – MrYoshiji Sep 20 '13 at 16:15
  • Okay, so after MUCH research, it turns out that not only was MrYoshiji mostly right, it turns out that there were two versions of ruby on the machine. And, many versions of gems. This has caused great issues. So, I am happy to give you credit, but the pain continues. Is there a way to completely clean a machine of all ruby and all gems so that I may start over? – Jerry Sep 20 '13 at 18:40

4 Answers4

9

I was able to to fix this problem on my system by running:

sudo yum install ruby193-ruby-devel.x86_64
user3362935
  • 106
  • 1
  • 3
4

RHELyum install scl-utils scl-utils-build

CENTOSyum install centos-release-SCL -y

yum install ruby193 ruby193-ruby-devel augeas-devel libxml2-devel -y
scl enable ruby193 "ruby -v"
scl enable ruby193 "bash"
gem install json -v '1.8.0'
xakru
  • 269
  • 2
  • 4
0

You may need to install following packages first:

yum install ruby-devel.x86_64 libxslt-devel libxml2-devel
Community
  • 1
  • 1
Jeffrey Ye
  • 89
  • 1
  • 1
  • 7
0

Step 1: Run below command on your terminal:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

Step 2: Install RVM Development version on your system:

\curl -sSL https://get.rvm.io | bash

For Latest version of Ruby i.e. 2.2.1 follow below steps:

\curl -sSL https://get.rvm.io | bash -s stable --ruby

After this step you should see a message like: To start using RVM you need to run source /home/user_name/.rvm/scripts/rvm in all your open shell windows, in rare cases you need to reopen all shell windows.

Step 3: Activate ruby using the message

Source /home/user_name/.rvm/scripts/rvm

Step 4: Check Ruby version

ruby --version

Step 5: Say thanks if it works ;)

Pawan
  • 1,537
  • 1
  • 15
  • 19
Krishna Sharma
  • 131
  • 2
  • 3
  • 12