ruby-build: Ruby 2.4.2 fails to build on Ubuntu 16.04
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
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 20 (2 by maintainers)
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-6instead of the current upstream version (which is 7). So, usually it looks like that:@casperl
According to a bug report, you shoud type:
I have not detected the root cause of the problem, I found a workaround:
opensslfrom the source:CONFIGURE_OPTSenvironment variable:[UPDATE]
You also need to install
cacert.pemin order to make SSL connections: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.
saved me installing an older Ruby version for a project I inherited.
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-deFor me these stuff have fixed issue.Purging rbenv and the ~/.rbenv directory and a clean install of rbenv performed. Running “rbenv install 2.3.1” produced a similar error:
You’re an angel!
@kuroda that worked for me. Thanks!
This issue was fixed at the first reporter.
@kubakrzempek
this worked very well.
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