Digitalchild.Info

Images, Thoughts and Sounds

  • Home
  • Contact

Gems when using Ruby via Software Collections

June 26, 2014 by Jamie Leave a Comment

In my previous article I outlined how to get Ruby installed via RedHat Software Collections (SCL) and this works for basic ruby commands until I tried to install my backup gem. I got an install error when trying to build the native extensions. This guide will show you how to install gems when using ruby via software collections.

[root@machine1 ~]# gem install backup
Building native extensions.  This could take a while...
ERROR:  Error installing backup:
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/atomic-1.1.14 for inspection.
Results logged to /opt/rh/ruby193/root/usr/local/share/gems/gems/atomic-1.1.14/ext/gem_make.out

I will need to install the relevant development tools to get this working. When installing ruby using other methods some how-to’s tell you to do the blanket install of all development tools. I want to make sure I run as lean an OS image as possible. So I will only install the required packages by running the following:


sudo yum install gcc gcc-c++ make automake autoconf curl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-devel ruby193-ruby-doc ruby193-ruby-devel ruby193-build

I now have everything I need to get gem to build the native extensions. So I run the command to install backup again and everything succeeds.


gem install backup

The only problem I have now is that when I try to run backup I get the following:

[root@machine1 ~]# backup
-bash: backup: command not found

This is because the gem was installed inside of the software collections path so we will need to add this path to our existing path.


echo "pathmunge /opt/rh/ruby193/root/usr/local/bin" | sudo tee -a /etc/profile.d/ruby193.sh

This is the same for any gems you install that need building. Once you’ve done the above gem install somegem commands will work.

Filed Under: Geek, Tip Tagged With: centos, gems, how to, linux, ruby, software collections

Centos 6.5 and Ruby 1.9.3 via Software Collections

June 26, 2014 by Jamie 2 Comments

I wanted to cut the amount of repositories that my systems were running and I recently came across Red Hats Software Collections (SCL). Software collections is a relatively new system that allows you to run some newer versions of popular packages including ruby, php, postgreSQL and more. I needed a newer version of Ruby (1.9.3) for my systems because I use a backup system that’s written in ruby from Michael van Rooijen. I know that Ruby 1.9.3 might not be new enough for some but it works for me. The following is a quick guide on how to get Centos 6.5 and Ruby 1.9.3 via software collections.

The standard CentOS repositories ships with software collections and its very easy to get them running. You can do so by running the following command.

yum install -y centos-release-SCL

This will then give you access to the standard SCL’s that ship with CentOS/RHEL. You can build your own software collections if you like but I won’t go into that with this post. Now you will have the newer versions available to install such as ruby193. Run the following to install ruby193.

yum install -y ruby193

I run minimal installs so I never have any other versions of software installed unless I need them so if I was to run ruby -v on the command line I would get the following:

[root@machine1 ~]# ruby -v
-bash: ruby: command not found

Now you might think that ruby hasn’t installed, it has it’s just not part of your path or current session. To enable ruby run the following command.

[root@machine1 ~]# source /opt/rh/ruby193/enable
[root@machine1 ~]# ruby -v
ruby 1.9.3p448 (2013-06-27) [x86_64-linux]

As you can see we’ve now got access to ruby 1.9.3 from the software collections. There is a whole bunch of ruby193 packages available you can find them using search with yum. As I don’t use the standard ruby packages at all I want to make the SCL version my default version. The above commands are great for the current session but you would have to run source  every login.  A nice way to make sure that this is working across logout and reboots is to put the source command in the profile.

echo "source /opt/rh/ruby193/enable" | sudo tee -a /etc/profile.d/ruby193.sh

This will make it available as default for all users.

Filed Under: Geek, Tip Tagged With: backup, centos, linux, ruby, software collections

Search

About Me

Hi, I'm Jamie aka digitalchild.

Jamie

I build things that work on the Internet and I've been doing this for over 15 years now. Take a look around and comment if you like.

Categories

  • Entertainment
  • Food
  • Games
  • Geek
  • Images
  • Music
  • Ramblings
  • Tip

Tags

angry panda apple australia backup camera centos chia cisco coconut data recovery easy email fitness gluten free healthy incompetence iphone iphone4 kale linux me microsoft mysql organic os x paleo programming quick raspberry pi raspbian recipe ruby salad software collections solution SSL sysadmin time lapse ubuntu vegan vmware vodafone winter wordpress xbox 360

Archives

  • July 2019
  • June 2015
  • May 2015
  • February 2015
  • January 2015
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • August 2013
  • August 2012
  • April 2012
  • August 2011
  • June 2011
  • May 2011
  • November 2010
  • October 2010
  • August 2010

My Projects

  • Live Coding
  • Off Grid Build
  • WC Vendors

Social Media

  • Instagram
  • Soundcloud
  • Twitter

Copyright © 2019 · Genesis Sample on Genesis Framework · WordPress · Log in