Skip to content
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

Open
kuroda opened this issue Nov 6, 2017 · 16 comments

Comments

Projects
None yet
@kuroda
Copy link

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

This comment has been minimized.

Copy link

commented Nov 13, 2017

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

commented Dec 8, 2017

@kuroda that worked for me. Thanks!

@kuroda

This comment has been minimized.

Copy link
Author

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
@vijaymca

This comment has been minimized.

Copy link

commented May 4, 2018

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

ruby error

@goermine

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Nov 27, 2018

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

This comment has been minimized.

Copy link

commented Feb 17, 2019

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link

commented Apr 17, 2019

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

This comment has been minimized.

Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.