Category: openshift

Ruby Gem install fails on Windows because of SSL

When installing the Openshift rhc client I need to install a Ruby gem on Windows. This resulted in an error message:

C:\Users\user>gem install rhc
ERROR:  Could not find a valid gem 'rhc' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect retur
          ned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (
    https://api.rubygems.org/latest_specs.4.8.gz)

This is because the Ruby network client is unable to verify the SSL Certificate Authority. Via Google a found a Gist
which explains how this can be fixed. I found the manual way the fastest way, since I
will not be using gem for other projects.

In short I did this:

Download http://curl.haxx.se/ca/cacert.pem to c:\temp

Executed in command prompt:
set SSL_CERT_FILE=c:\temp\cacert.pem

After this executing the command to install the client tools worked:

C:\temp>gem install rhc
Fetching: net-ssh-2.9.2.beta.gem (100%)
Successfully installed net-ssh-2.9.2.beta
Fetching: net-scp-1.2.1.gem (100%)
Successfully installed net-scp-1.2.1
Fetching: net-ssh-gateway-1.2.0.gem (100%)
Successfully installed net-ssh-gateway-1.2.0
Fetching: net-ssh-multi-1.2.0.gem (100%)
Successfully installed net-ssh-multi-1.2.0
Fetching: archive-tar-minitar-0.5.2.gem (100%)
Successfully installed archive-tar-minitar-0.5.2
Fetching: highline-1.6.21.gem (100%)
Successfully installed highline-1.6.21
Fetching: commander-4.2.1.gem (100%)
Successfully installed commander-4.2.1
Fetching: httpclient-2.5.3.3.gem (100%)
Successfully installed httpclient-2.5.3.3
Fetching: open4-1.3.4.gem (100%)
Successfully installed open4-1.3.4
Fetching: rhc-1.33.4.gem (100%)
===========================================================================

If this is your first time installing the RHC tools, please run 'rhc setup'

===========================================================================
Successfully installed rhc-1.33.4
Parsing documentation for archive-tar-minitar-0.5.2
Installing ri documentation for archive-tar-minitar-0.5.2
Parsing documentation for commander-4.2.1
Installing ri documentation for commander-4.2.1
Parsing documentation for highline-1.6.21
Installing ri documentation for highline-1.6.21
Parsing documentation for httpclient-2.5.3.3
Installing ri documentation for httpclient-2.5.3.3
Parsing documentation for net-scp-1.2.1
Installing ri documentation for net-scp-1.2.1
Parsing documentation for net-ssh-2.9.2.beta
Installing ri documentation for net-ssh-2.9.2.beta
Parsing documentation for net-ssh-gateway-1.2.0
Installing ri documentation for net-ssh-gateway-1.2.0
Parsing documentation for net-ssh-multi-1.2.0
Installing ri documentation for net-ssh-multi-1.2.0
Parsing documentation for open4-1.3.4
Installing ri documentation for open4-1.3.4
Parsing documentation for rhc-1.33.4
Installing ri documentation for rhc-1.33.4
Done installing documentation for archive-tar-minitar, commander, highline, http
client, net-scp, net-ssh, net-ssh-gateway, net-ssh-multi, open4, rhc after 27 se
conds
10 gems installed

Home

After fixing the SSL issue I encountered a second problem during the setup command, after the SSH key step
the client would attempt to write a file to the H:\ drive. It assumed that that was my homedrive, while it does not exist.

Generating an authorization token for this client ... C:/Ruby21-x64/lib/ruby/2.1
.0/fileutils.rb:250:in `mkdir': No such file or directory @ dir_s_mkdir - H: (Er
rno::ENOENT)
        from C:/Ruby21-x64/lib/ruby/2.1.0/fileutils.rb:250:in `fu_mkdir'
        from C:/Ruby21-x64/lib/ruby/2.1.0/fileutils.rb:224:in `block (2 levels)
in mkdir_p'
        from C:/Ruby21-x64/lib/ruby/2.1.0/fileutils.rb:222:in `reverse_each'
        from C:/Ruby21-x64/lib/ruby/2.1.0/fileutils.rb:222:in `block in mkdir_p'

        from C:/Ruby21-x64/lib/ruby/2.1.0/fileutils.rb:208:in `each'
        from C:/Ruby21-x64/lib/ruby/2.1.0/fileutils.rb:208:in `mkdir_p'
        from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/rhc-1.33.4/lib/rhc/auth/toke
n_store.rb:34:in `[]='
        from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/rhc-1.33.4/lib/rhc/auth/toke
n_store.rb:14:in `put'
        from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/rhc-1.33.4/lib/rhc/auth/toke
n.rb:50:in `save'
        from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/rhc-1.33.4/lib/rhc/wizard.rb
:243:in `block in login_stage'
        from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/rhc-1.33.4/lib/rhc/highline_
extensions.rb:190:in `call'

It turns out that there are two environment variables that define the HOME folder on Windows: HOMEPATH and HOMEDRIVE. Set
the combination of these two to a writable folder. For example to your user dir on Windows. These environment variables can be
set in two ways: via the commandline (where they will be forgotten after closing the shell windows), or via the Advanced Properties
of the About dialog of My Computer.

The simplest way via the commandline is:

    SET HOMEPATH=\users\user
    SET HOMEDRIVE=C:

Leave a Comment