1

I only had ruby 2.0 on my system. I tried to install mechanize gem. It gave me an error which told me to install ruby devkit. I installed devkit as follows - Download the installer/extractor > extract devkit to c:\devkit > cd into c:\devkit > add the path c:\Ruby200-x64 into the config.yml file > ruby dk.rb init > ruby dk.rb install. Then I got the error below. How can this be fixed ?

config.yml file -

# Example:
#
# ---
# - C:/ruby19trunk
# - C:/ruby192dev
#
---
- C:\Ruby200-x64

Error -

C:\Ruby2Devkit>gem install mechanize
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing mechanize:
        ERROR: Failed to build gem native extension.

    C:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for main() in -lstdc++... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby200-x64/bin/ruby
        --with-stdc++lib
        --without-stdc++lib
C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed 
to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:534:in `try_link'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:720:in `try_func'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:950:in `block in 
        have_library'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:895:in `block in 
        checking_for'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) 
        in postpone'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:310:in `open'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:310:in `open'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
        from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:945:in `have_library'
        from extconf.rb:2:in `<main>'


Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/
2.0.0/gems/unf_ext-0.0.6 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/unf_ext-0.0.6/
ext/unf_ext/gem_make.out
Erran Morad
  • 4,563
  • 10
  • 43
  • 72

2 Answers2

2

If possible, please upvote this guy, whose answer helped me - https://stackoverflow.com/a/16579164/3184475

I spent hours trying to figure out a way to get this right using my existing ruby installation. I installed devkit and mingw (base and dev tools). Nothing helped ! I could not install any of the gems that mattered.

Solution - Delete your devkit. Uninstall your ruby. Install RailsInstaller from - http://railsinstaller.org/en

You will get some extra software with this installer. But, who cares ? It will save you 5 hours of frustration, googling, running commands and following steps about which you have no clue. If you are not allowed to do that, then prepare for hell.

After you install this software, go to cmd and run ruby -v to check which ruby you have.


When you try to install a gem, you might get some ssl security certificate errors like - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

The solution is here - https://gist.github.com/luislavena/f064211759ee0f806c88

I have the main steps from the above link which worked for me. I suggest you read the whole article though.

Step 1: Obtain the new trust certificate If you've read the previous sections, you will know what this means (and shame on you if you have not).

We need to download AddTrustExternalCARoot-2048.pem.

Use the above link and place/save this file somewhere you can later find easily (eg. your Desktop).

IMPORTANT: File must have .pem as extension. Browsers like Chrome will try to save it as plain text file. Ensure you change the filename to have .pem in it after you have downloaded it.

Step 2: Locate RubyGems certificate directory in your installation In order for us copy this file, we need to know where to put it.

Depending on where you installed Ruby, the directory will be different.

Take for example the default installation of Ruby 2.1.5, placed in C:\Ruby21

Open a Command Prompt and type in:

C:\>gem which rubygems
C:/Ruby21/lib/ruby/2.1.0/rubygems.rb

Now, let's locate that directory. From within the same window, enter the path part up to the file extension, but using backslashes instead:

C:\>start C:\Ruby21\lib\ruby\2.1.0\rubygems

This will open a Explorer window inside the directory we indicated.

Step 3: Copy new trust certificate Now, locate ssl_certs directory and copy the .pem file we obtained from previous step inside.

It will be listed with other files like GeoTrustGlobalCA.pem.

Step 4: Profit There is actually no step 4. You should be able to install Ruby gems without issues now.

In case you can't get that file AddTrustExternalCARoot-2048.pem, you can use the text below and save it as a .pem file.

-----BEGIN CERTIFICATE-----
MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU
MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs
IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290
MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux
FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h
bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v
dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt
H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9
uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX
mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX
a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN
E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0
WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD
VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0
Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU
cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx
IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN
AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH
YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5
6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC
Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX
c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a
mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=
-----END CERTIFICATE-----
Community
  • 1
  • 1
Erran Morad
  • 4,563
  • 10
  • 43
  • 72
0

Side note for OSX users. You may just need to accept XCode License sudo xcodebuild -license In any case, take a look at mkmf.log for more details

jrenouard
  • 407
  • 6
  • 8