ruby rbenv install 2.0.0-p247 fail for Centos

rbenv 를 이용해서 ruby 2.0.0 p247을 설치할 때 에러가 발생한다. centos 6.5에서 발생했다.

해결법을 기록해둔다. 참고가 되길 바란다.

ref web site

rbenv install 2.0.0-p247

위의 명령을 실행했을 때 아래 상황 발생

problem:

BUILD FAILED

Inspect or clean up the working tree at /tmp/ruby-build.20150424111036.5089
Results logged to /tmp/ruby-build.20150424111036.5089.log

Last 10 log lines:
ossl_pkey_ec.c:821: error: for each function it appears in.)
make[2]: *** [ossl_pkey_ec.o] Error 1
make[2]: Leaving directory `/tmp/ruby-build.20150424111036.5089/ruby-2.0.0-p247/ext/openssl'
make[1]: *** [ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
installing default callback libraries
linking shared-object dl/callback.so
make[2]: Leaving directory `/tmp/ruby-build.20150424111036.5089/ruby-2.0.0-p247/ext/dl/callback'
make[1]: Leaving directory `/tmp/ruby-build.20150424111036.5089/ruby-2.0.0-p247'
make: *** [build-ext] Error 2

solution:

1. Create “patch.diff” file.
2. Copy the content below.

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41807)
+++ ChangeLog	(revision 41808)
@@ -1,3 +1,16 @@
+Sat Jul  6 07:37:43 2013  Martin Bosslet  <Martin.Bosslet@gmail.com>
+
+	* ext/openssl/ossl_pkey_ec.c: Ensure compatibility to builds of
+	  OpenSSL with OPENSSL_NO_EC2M defined, but OPENSSL_NO_EC not
+	  defined.
+	* test/openssl/test_pkey_ec.rb: Iterate over built-in curves
+	  (and assert their non-emptiness!) instead of hard-coding them, as
+	  this may cause problems with respect to the different availability
+	  of individual curves in individual OpenSSL builds.
+	  [ruby-core:54881] [Bug #8384]
+
+	  Thanks to Vit Ondruch for providing the patch!
+
 Sat Jul  6 07:12:39 2013  Martin Bosslet  <Martin.Bosslet@gmail.com>
 
 	* test/openssl/test_x509crl.rb: Remove unused variable.
Index: ext/openssl/ossl_pkey_ec.c
===================================================================
--- ext/openssl/ossl_pkey_ec.c	(revision 41807)
+++ ext/openssl/ossl_pkey_ec.c	(revision 41808)
@@ -762,8 +762,10 @@
                 method = EC_GFp_mont_method();
             } else if (id == s_GFp_nist) {
                 method = EC_GFp_nist_method();
+#if !defined(OPENSSL_NO_EC2M)
             } else if (id == s_GF2m_simple) {
                 method = EC_GF2m_simple_method();
+#endif
             }
 
             if (method) {
@@ -817,8 +819,10 @@
 
             if (id == s_GFp) {
                 new_curve = EC_GROUP_new_curve_GFp;
+#if !defined(OPENSSL_NO_EC2M)
             } else if (id == s_GF2m) {
                 new_curve = EC_GROUP_new_curve_GF2m;
+#endif
             } else {
                 ossl_raise(rb_eArgError, "unknown symbol, must be :GFp or :GF2m");
             }
Index: test/openssl/test_pkey_ec.rb
===================================================================
--- test/openssl/test_pkey_ec.rb	(revision 41807)
+++ test/openssl/test_pkey_ec.rb	(revision 41808)
@@ -7,28 +7,28 @@
     @data1 = 'foo'
     @data2 = 'bar' * 1000 # data too long for DSA sig
 
-    @group1 = OpenSSL::PKey::EC::Group.new('secp112r1')
-    @group2 = OpenSSL::PKey::EC::Group.new('sect163k1')
-    @group3 = OpenSSL::PKey::EC::Group.new('prime256v1')
+    @groups = []
+    @keys = []
 
-    @key1 = OpenSSL::PKey::EC.new
-    @key1.group = @group1
-    @key1.generate_key
+    OpenSSL::PKey::EC.builtin_curves.each do |curve, comment|
+      group = OpenSSL::PKey::EC::Group.new(curve)
 
-    @key2 = OpenSSL::PKey::EC.new(@group2.curve_name)
-    @key2.generate_key
+      key = OpenSSL::PKey::EC.new(group)
+      key.generate_key
 
-    @key3 = OpenSSL::PKey::EC.new(@group3)
-    @key3.generate_key
-
-    @groups = [@group1, @group2, @group3]
-    @keys = [@key1, @key2, @key3]
+      @groups << group
+      @keys << key
+    end
   end
 
   def compare_keys(k1, k2)
     assert_equal(k1.to_pem, k2.to_pem)
   end
 
+  def test_builtin_curves
+    assert(!OpenSSL::PKey::EC.builtin_curves.empty?)
+  end
+
   def test_curve_names
     @groups.each_with_index do |group, idx|
       key = @keys[idx]

3. Create “fedora.configure” file
4. Copy the content below.

#!/bin/sh
patch -p0 -i /tmp/patch.diff
exec ./configure "$@"

5. Execute this command.

RUBY_CONFIGURE=/home/user/fedora-configure rbenv install 2.0.0-p247

6. check ruby version.

rbenv versions

글쓴이

Kwon

github: https://github.com/9to6