Cannot install Ruby Gem – certificate error

I just encountered a problem trying to install first the rails gem and then the watir gem.

I executed:

$ gem install rails

it failed with an OpenSSL error, a bit later I tried to install watir using:

$ gem install watir

I was surprised to see that it also failed with

# Unable to download data from - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (

I wondered it might have something to with the fact that I am using rvm to manage my ruby environments, it turns out that it does indeed. It seems that the certificates in rvm must be updated manually every so often.

If you check the status of the certificates in rvm by running:

$ rvm osx-ssl-certs status all

you will probably see

# Certificates for /etc/openssl/cert.pem: Old.

to update them, run:

$ rvm osx-ssl-certs update all

(Note – you may need to enter your password.)

Hey presto, your problem should be resolved!

Testing iOS apps with calabash – PART 2

In the last chapter we installed lots of goodies to make our mac a more productive environment and one more conducive to using on.

In this chapter we will configure our bash_profile so that rvm is available every time we use the terminal window, then we will install and finally at the end of the chapter we will runs test using


RVM is a version manager for Ruby. It allows us to switch between versions of Ruby. You may have several projects going as once and each project may be built on a different version of Ruby. Instead of hacking your system around and making a pigs ear of things, rvm does all the heavy lifting, allowing us to install and switch ruby versions in one simple command line statement.

Now – if you’ve followed my instructions in Chapter 1, you will have ruby v2 installed.

Now if we want to instal other versions of ruby we can use dvm to manage them, but when I tried running

$ rvm install 1.9.2

to install version 1.9.2, I ran into a problem – basically the installer hung at the gcc part – so I had to do the following:

$ brew update

$ brew tap homebrew/dupes

$ brew install autoconf automake apple-gcc42

$ rvm pkg install openssl

$ rvm reinstall all —force

$ sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2

$ rvm install 1.9.2

So now ruby 1.9.2 is installed let’s just take a look at the list of rubies that we have on our system and which one we are using, we do this by typing:

$ rvm list

my response is:

rvm rubies
ruby-1.9.2-p320 [ x86_64 ]
=* ruby-2.0.0-p247 [ x86_64 ]
=> – current
=* – current && default
* – default

This shows us that we have ruby 1.9.2 and ruby 2.0.0 installed and that we are using ruby 2.0.0 as our current and default ruby installation.

Please note, each time you use rvm it is a good idea to make sure you have the latest version. You can do this by entering:

$ rvm get stable —autolibs=enable.

Now using rvm, if you want to set 1.9.2 as the default version you can ruby version you can just issue the command:

$ rvm use 1.9.2

RVM is a useful tool. I suggest you take a look at to find more info on how to change your default, check paths to you versions etc.

Our App We’re going to need something to test against. If you don’t already have the source code for an app, has a sample app that we can use. To get the source code we need to get it from Github. To do this we do what is called “clone” the git repository. The git repository is: and to ‘clone’ the github repository (repo) we do the following: cd into the folder where you will keep your apps source code, then issue the command to clone the repo:

$ git clone

this will make a calabash-ios-example folder containing the source code for the App.

Do the set up

In terminal, cd to your app folder, in my case, this is:

$ cd ~/App/calabash-ios-example/

then install the calabash-cucumber gem:

$ sudo gem install calabash-cucumber

then run the calabash project set up:

$ calabash-ios setup

Then follow the instructions in your terminal console. This is done by running the -cal target from Xocde.

First we’ll do this, then I’ll explain what we’ve just done.

In Xcode, open the .xcodeprojfile for your app – this is in the folder LPSimpleExample if using the sample app.

Then, go to the scheme toolbar – in my workspace it’s under Product > Scheme. Select the app which is post fixed with -cal, in my case LPSimpleExample-cal

Build the app.

The simulator will start and in the in the application log (which is in the bottom right of your Xcode workspace) you will find a message which say “Started LPHTTP server on port xxxxxx” – this verifies that your project has been built and is running under calabash.

What we have done here is instruct the app to use the calabash framework (hence the postfix -cal)

Finally, we can generate the skeleton folders for our tests:

$ calabash-ios gen

then run our first test:

$ cucumber

We should see 1 passed scenario and 4 passed steps.

That’s us set up and ready to rock and roll.

Next chapter – diving deeper – writing our own tests