Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 2.4.2 fails to build on Ubuntu 16.04 #1146

Closed
kuroda opened this issue Nov 6, 2017 · 20 comments
Closed

Ruby 2.4.2 fails to build on Ubuntu 16.04 #1146

kuroda opened this issue Nov 6, 2017 · 20 comments

Comments

@kuroda
Copy link

kuroda commented Nov 6, 2017

I have installed Ruby 2.4.1 successfully on my Ubuntu 16.04 Desktop, but failed to build Ruby 2.4.2.

Here are the last lines of error log:

make[2]: Entering directory '/tmp/ruby-build.20171106150424.32381/ruby-2.4.2/ext/digest/md5'
compiling md5init.c
linking shared-object digest/md5.so
/usr/bin/ld: /usr/local/lib/libcrypto.a(md5_dgst.o): relocation R_X86_64_PC32 against symbol `md5_block_asm_data_order' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Makefile:262: recipe for target '../../../.ext/x86_64-linux/digest/md5.so' failed
make[2]: *** [../../../.ext/x86_64-linux/digest/md5.so] Error 1
make[2]: Leaving directory '/tmp/ruby-build.20171106150424.32381/ruby-2.4.2/ext/digest/md5'
exts.mk:198: recipe for target 'ext/digest/md5/all' failed
make[1]: *** [ext/digest/md5/all] Error 2
make[1]: Leaving directory '/tmp/ruby-build.20171106150424.32381/ruby-2.4.2'
uncommon.mk:220: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2
@Lewington-pitsos
Copy link

I have the same problem on ubuntu 17.10 for all ruby versions I have tried to install

Re-installing rbenv did not seem to help.

@kuroda
Copy link
Author

kuroda commented Nov 13, 2017

[UPDATE]

I succeeded to install Ruby 2.4.2 on the clean installed Ubuntu 16.04 Desktop.

It seems that something goes wrong on my working Ubuntu 16.04.

I will close this issue after researching just a little bit more.

@kuroda
Copy link
Author

kuroda commented Nov 13, 2017

I have not detected the root cause of the problem, I found a workaround:

  1. Build openssl from the source:
$ cd /tmp
$ curl -LO https://www.openssl.org/source/openssl-1.1.0f.tar.gz
$ tar xvfz openssl-1.1.0f.tar.gz
$ cd openssl-1.1.0f
$ ./config --prefix=/opt/openssl/1.1.0f
$ make
$ sudo make install
  1. Build ruby with CONFIGURE_OPTS environment variable:
$ CONFIGURE_OPTS="--with-openssl-dir=/opt/openssl/1.1.0f" rbenv install 2.4.2

[UPDATE]

You also need to install cacert.pem in order to make SSL connections:

$ sudo wget -O /opt/openssl/1.1.0f/ssl/cert.pem http://curl.haxx.se/ca/cacert.pem

@casperl
Copy link

casperl commented Nov 17, 2017

I have the same problem. Apt-Get installed versiion on Ubuntu 17.10 is Ruby Build version: 20161225-1
No version of Ruby installs now through rbenv. Error reportd:
BUILD FAILED (Ubuntu 17.10 using ruby-build 20170914-5-gf41e847) .... ends in "segmentation fault, core dumped."
Since rbenv appears to have a gem version of ruby-build (did "gem update" under rbenv do this, because I did not?) I issued "gem uninstall ruby-build) and ran "rbenv install 2.3.1" using the Ubuntu installed version of Ruby-Build, but the same error and version number of Ruby-build appears.

Next step to is to uninstall + purge rbenv and to sea if Ubuntu supplied Ruby will be sufficient for my needs.

@casperl
Copy link

casperl commented Nov 17, 2017

Purging rbenv and the ~/.rbenv directory and a clean install of rbenv performed.
Running "rbenv install 2.3.1" produced a similar error:
image

@kuroda
Copy link
Author

kuroda commented Nov 17, 2017

@casperl I think your problem is different from mine.

I don't encounter with any segmentation faults. My problem is related to linker.

@kuroda
Copy link
Author

kuroda commented Nov 17, 2017

@casperl

According to a bug report, you shoud type:

$ sudo apt-get install gcc-6 g++-6
$ CC=/usr/bin/gcc-6 rbenv install 2.3.1

@m-rwash
Copy link

m-rwash commented Dec 8, 2017

@kuroda that worked for me. Thanks!

@kuroda
Copy link
Author

kuroda commented Dec 25, 2017

Upon the release of Ruby 2.5.0, I tried to build on my Ubuntu 16.04. I got following error messages:

BUILD FAILED (Ubuntu 16.04 using ruby-build 20171215-3-ga97a138)

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

Last 10 log lines:
make[2]: Leaving directory '/tmp/ruby-build.20171226020853.23177/ruby-2.5.0/ext/digest/sha1'
exts.mk:259: recipe for target 'ext/digest/sha1/all' failed
make[1]: *** [ext/digest/sha1/all] Error 2
linking shared-object digest.so
make[2]: Leaving directory '/tmp/ruby-build.20171226020853.23177/ruby-2.5.0/ext/continuation'
make[2]: Leaving directory '/tmp/ruby-build.20171226020853.23177/ruby-2.5.0/ext/-test-/string'
make[2]: Leaving directory '/tmp/ruby-build.20171226020853.23177/ruby-2.5.0/ext/digest'
make[1]: Leaving directory '/tmp/ruby-build.20171226020853.23177/ruby-2.5.0'
uncommon.mk:240: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2

As I did for Ruby 2.4.2, after building the openssl from the source, I succeeded to compile ruby with this command:

CONFIGURE_OPTS="--with-openssl-dir=/opt/openssl/1.1.0f" rbenv install 2.5.0

@mrvijaycode
Copy link

I am also getting the similar error, please could you help me.

ruby error

@goermine
Copy link

goermine commented Jul 25, 2018

Did you try to install this (below) list of dependency to your Ubuntu system ?:
sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-de
For me these stuff have fixed issue.

@kubakrzempek
Copy link

As far as I know, (and tested) Ruby versions < 2.4 requires libssl1.0, while >2.4 libssl1.1+. The two libssl packages conflict with each other, so you can't have both of them, so I had to juggle the libs in order to install the required ruby version. To make things even funnier (or more complicated), Ruby <2.4 tends to require gcc-6 instead of the current upstream version (which is 7).
So, usually it looks like that:

# for ruby <2.4
apt install libssl1.0-dev
CC=$(which gcc-6) rbenv install `version`

# for ruby >2.4
apt install libssl-dev
rbenv install `version`

@RaminMammadzada
Copy link

I also faced this problem. This resource helped me to solve the problem.
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rvm-on-ubuntu-18-04

@MatzFan
Copy link
Contributor

MatzFan commented Mar 22, 2019

Can this issue not be closed, as both the gcc-6 and libssl dependencies for earlier Rubies are documented in the wiki (here and here)?

After installing gcc-6 and libssl1.0-dev I was able to install both pre and post 2.4 Rubies on Ubuntu 18.04 as per the solution offered by @kubakrzempek without a problem. BTW it appears I do have both libssl libraries installed:

$ /sbin/ldconfig -pv|grep libssl
   libssl3.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libssl3.so
   libssl.so.1.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libssl.so.1.1
   libssl.so.1.0.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0
   libssl.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libssl.so

@robclancy
Copy link

Why should it be closed? What's the point of using a tool that works with all ruby envs if you have to dive into the docs for a compile error? At the very least it should check for these dependencies before building and get them or tell you they are missing so you can install them.

@jmig5776
Copy link

jmig5776 commented May 12, 2019

@kubakrzempek

# for ruby <2.4
apt install libssl1.0-dev
CC=$(which gcc-6) rbenv install `version`

# for ruby >2.4
apt install libssl-dev
rbenv install `version`

this worked very well.

@bcawrse
Copy link

bcawrse commented Aug 14, 2019

# for ruby <2.4
apt install libssl1.0-dev
CC=$(which gcc-6) rbenv install `version`

# for ruby >2.4
apt install libssl-dev
rbenv install `version`

saved me installing an older Ruby version for a project I inherited.

@patrickemuller
Copy link

As far as I know, (and tested) Ruby versions < 2.4 requires libssl1.0, while >2.4 libssl1.1+. The two libssl packages conflict with each other, so you can't have both of them, so I had to juggle the libs in order to install the required ruby version. To make things even funnier (or more complicated), Ruby <2.4 tends to require gcc-6 instead of the current upstream version (which is 7).
So, usually it looks like that:

# for ruby <2.4
apt install libssl1.0-dev
CC=$(which gcc-6) rbenv install `version`

# for ruby >2.4
apt install libssl-dev
rbenv install `version`

You're an angel!

@hsbt
Copy link
Member

hsbt commented Dec 31, 2020

This issue was fixed at the first reporter.

@hsbt hsbt closed this as completed Dec 31, 2020
@AhlamHani
Copy link

any other solutions? all of them didn't work for me, I'm using ruby-install 2.6.3

make[2]: Entering directory '/home/ahlam/src/ruby-2.6.3/ext/stringio'
compiling stringio.c
stringio.c: In function 'strio_ungetbyte':
stringio.c:814:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
         VALUE v = rb_funcall(c, rb_intern("modulo"), 1, INT2FIX(256));
         ^~~~~
stringio.c:822:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     const char *cp = RSTRING_PTR(c);
     ^~~~~
stringio.c: At top level:
cc1: warning: unrecognized command line option '-Wno-self-assign'
cc1: warning: unrecognized command line option '-Wno-parentheses-equality'
cc1: warning: unrecognized command line option '-Wno-constant-logical-operand'
cc1: warning: unrecognized command line option '-Wno-cast-function-type'
linking shared-object stringio.so
make[2]: Leaving directory '/home/ahlam/src/ruby-2.6.3/ext/stringio'
make[2]: Entering directory '/home/ahlam/src/ruby-2.6.3/ext/rbconfig/sizeof'
compiling sizes.c
compiling limits.c
linking shared-object rbconfig/sizeof.so
make[2]: Leaving directory '/home/ahlam/src/ruby-2.6.3/ext/rbconfig/sizeof'
make[2]: Entering directory '/home/ahlam/src/ruby-2.6.3/ext/bigdecimal'
compiling bigdecimal.c
linking shared-object bigdecimal.so
installing default bigdecimal libraries
make[2]: Leaving directory '/home/ahlam/src/ruby-2.6.3/ext/bigdecimal'
make[2]: Entering directory '/home/ahlam/src/ruby-2.6.3/ext/bigdecimal/util'
compiling util.c
linking shared-object bigdecimal/util.so
make[2]: Leaving directory '/home/ahlam/src/ruby-2.6.3/ext/bigdecimal/util'
make[2]: Entering directory '/home/ahlam/src/ruby-2.6.3/ext/json'
installing default libraries
make[2]: Leaving directory '/home/ahlam/src/ruby-2.6.3/ext/json'
make[2]: Entering directory '/home/ahlam/src/ruby-2.6.3/ext/json/generator'
compiling generator.c
linking shared-object json/ext/generator.so
make[2]: Leaving directory '/home/ahlam/src/ruby-2.6.3/ext/json/generator'
make[2]: Entering directory '/home/ahlam/src/ruby-2.6.3/ext/json/parser'
compiling parser.c
linking shared-object json/ext/parser.so
make[2]: Leaving directory '/home/ahlam/src/ruby-2.6.3/ext/json/parser'
make[2]: Entering directory '/home/ahlam/src/ruby-2.6.3/ext/fiber'
compiling fiber.c
linking shared-object fiber.so
make[2]: Leaving directory '/home/ahlam/src/ruby-2.6.3/ext/fiber'
make[2]: Entering directory '/home/ahlam/src/ruby-2.6.3/ext/ripper'
extracting ripper.y from ../.././parse.y
compiling compiler ripper.y
ripper.y:761.1-12: warning: deprecated directive: ‘%pure-parser’, use ‘%define api.pure’ [-Wdeprecated]
  761 | %pure-parser
      | ^~~~~~~~~~~~
      | %define api.pure
ripper.y: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
generating eventids1.c from ../.././parse.y
generating eventids2table.c from ../.././ext/ripper/eventids2.c
compiling ripper.c
ripper.c: In function 'ripper_yyparse':
ripper.c:5400:12: error: 'YYEMPTY' undeclared (first use in this function)
   yychar = YYEMPTY; /* Cause a token to be read.  */
            ^~~~~~~
ripper.c:5400:12: note: each undeclared identifier is reported only once for each function it appears in
ripper.c:5531:22: error: 'YYerror' undeclared (first use in this function)
   if (yychar <= END_OF_INPUT)
                      ^~~~~~~
ripper.c:5537:16: error: 'YYUNDEF' undeclared (first use in this function)
   else if (yychar == YYerror)
                ^~~~~~~
ripper.c:10702:51: error: macro "yydestruct" passed 5 arguments, but takes just 3
           if (yychar == END_OF_INPUT)
                                                   ^
ripper.c:10701:11: error: 'yydestruct' undeclared (first use in this function)
           /* Return failure if at end of input.  */
           ^~~~~~~~~~
ripper.c:10758:65: error: macro "yydestruct" passed 5 arguments, but takes just 3
       /* Pop the current state because it cannot handle the error token.  */
                                                                 ^
ripper.c:10814:47: error: macro "yydestruct" passed 5 arguments, but takes just 3
   if (yychar != YYEMPTY)
                                               ^
ripper.c:10823:65: error: macro "yydestruct" passed 5 arguments, but takes just 3
      this YYABORT or YYACCEPT.  */
                                                                 ^
At top level:
ripper.y:9127:1: warning: 'parser_token_value_print' defined but not used [-Wunused-function]
 parser_token_value_print(struct parser_params *p, enum yytokentype type, const YYSTYPE *valp)
 ^~~~~~~~~~~~~~~~~~~~~~~~
ripper.c:5303:1: warning: 'ruby_parser_yydestruct' defined but not used [-Wunused-function]
 ruby_parser_yydestruct (const char *yymsg,
 ^~~~~~~~~~~~~~~~~~~~~~
cc1: warning: unrecognized command line option '-Wno-self-assign'
cc1: warning: unrecognized command line option '-Wno-parentheses-equality'
cc1: warning: unrecognized command line option '-Wno-constant-logical-operand'
cc1: warning: unrecognized command line option '-Wno-cast-function-type'
make[2]: *** [Makefile:287: ripper.o] Error 1
make[2]: Leaving directory '/home/ahlam/src/ruby-2.6.3/ext/ripper'
make[1]: *** [exts.mk:254: ext/ripper/all] Error 2
make[1]: Leaving directory '/home/ahlam/src/ruby-2.6.3'
make: *** [uncommon.mk:286: build-ext] Error 2
!!! Compiling ruby 2.6.3 failed!

@rbenv rbenv locked and limited conversation to collaborators Jan 16, 2023
@hsbt hsbt converted this issue into discussion #2126 Jan 16, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests