rbenv / ruby-build

A tool to download, compile, and install Ruby on Unix-like systems.
https://rbenv.org/man/ruby-build.1
MIT License
3.89k stars 784 forks source link

2.2.0 Build fails on Ubuntu 14.04.1 (x86_64) #690

Closed endgame closed 9 years ago

endgame commented 9 years ago

ruby-build version:

20141225-1-g45b75ed

The acutal error is:

linking shared-object fiddle.so
/usr/bin/ld: ./libffi-3.2.1/.libs/libffi.a(raw_api.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC

I've included the full build log below, please let me know if you need me to test anything or I can give you better information:

/tmp/ruby-build.20141225215042.17047 /vagrant
Downloading ruby-2.2.0.tar.gz...
HTTP/1.1 200 OK
Content-Type: binary/octet-stream
Content-Length: 16494584
Connection: keep-alive
Date: Thu, 25 Dec 2014 11:08:01 GMT
Last-Modified: Thu, 25 Dec 2014 10:02:26 GMT
ETag: "cd03b28fd0b555970f5c4fd481700852"
Accept-Ranges: bytes
Server: AmazonS3
Age: 38568
X-Cache: Hit from cloudfront
Via: 1.1 f4bd0fa1d2fc98fb3b1433c4363b95c5.cloudfront.net (CloudFront)
X-Amz-Cf-Id: V02lmRmjOiRevHt69a4TLVEnXUV2CrbCthwribvZvRVeZGsN_NAf_Q==

-> http://dqw8nmjcqpjn7.cloudfront.net/7671e394abfb5d262fbcd3b27a71bf78737c7e9347fa21c39e58b0bb9c4840fc
/tmp/ruby-build.201412252config.guess already exists
config.sub already exists
checking build system type... x86_64-unknown-linux-gnu
(snip)
compiling conversions.c
make[3]: Entering directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1'
make 'AR_FLAGS=' 'CC_FOR_BUILD=' 'CFLAGS=-O3 -fno-fast-math -ggdb3  -Wall -fexceptions' 'CXXFLAGS=-O3 -fno-fast-math -ggdb3 ' 'CFLAGS_FOR_BUILD=' 'CFLAGS_FOR_TARGET=' 'INSTALL=/usr/bin/install -c' 'INSTALL_DATA=/usr/bin/install -c -m 644' 'INSTALL_PROGRAM=/usr/bin/install -c' 'INSTALL_SCRIPT=/usr/bin/install -c' 'JC1FLAGS=' 'LDFLAGS=-L. -L/home/vagrant/.rbenv/versions/2.2.0/lib  -fstack-protector -rdynamic -Wl,-export-dynamic  -L../../.. ' 'LIBCFLAGS=' 'LIBCFLAGS_FOR_TARGET=' 'MAKE=make' 'MAKEINFO=/bin/bash /tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1/missing makeinfo ' 'PICFLAG=' 'PICFLAG_FOR_TARGET=' 'RUNTESTFLAGS=' 'SHELL=/bin/bash' 'exec_prefix=/usr/local' 'infodir=/usr/local/share/info' 'libdir=/home/vagrant/.rbenv/versions/2.2.0/lib' 'mandir=/usr/local/share/man' 'prefix=/usr/local' 'AR=ar' 'AS=as' 'CC=gcc' 'CXX=g++' 'LD=ld -m elf_x86_64' 'NM=/usr/bin/nm -B' 'RANLIB=ranlib' 'DESTDIR=' all-recursive
make[4]: Entering directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1'
Making all in include
make[5]: Entering directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1/include'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1/include'
Making all in testsuite
make[5]: Entering directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1/testsuite'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1/testsuite'
Making all in man
make[5]: Entering directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1/man'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1/man'
make[5]: Entering directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1'
  CC       src/prep_cif.lo
  CC       src/types.lo
  CC       src/raw_api.lo
  CC       src/java_raw_api.lo
  CC       src/closures.lo
src/closures.c: In function 'dlmmap_locked':
src/closures.c:488:17: warning: ignoring return value of 'ftruncate', declared with attribute warn_unused_result [-Wunused-result]
       ftruncate (execfd, offset);
                 ^
src/closures.c:500:17: warning: ignoring return value of 'ftruncate', declared with attribute warn_unused_result [-Wunused-result]
       ftruncate (execfd, offset);
                 ^
  CC       src/x86/ffi64.lo
  CPPAS    src/x86/unix64.lo
  CC       src/x86/ffi.lo
  CPPAS    src/x86/sysv.lo
  CCLD     libffi_convenience.la
  CCLD     libffi.la
make[5]: Leaving directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1'
make[4]: Leaving directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1'
make[3]: Leaving directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1'
linking shared-object fiddle.so

BUILD FAILED (Ubuntu 14.04 using ruby-build 20141225-1-g45b75ed)

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

Last 10 log lines:
make[3]: Leaving directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle/libffi-3.2.1'
linking shared-object fiddle.so
/usr/bin/ld: ./libffi-3.2.1/.libs/libffi.a(raw_api.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
./libffi-3.2.1/.libs/libffi.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [../../.ext/x86_64-linux/fiddle.so] Error 1
make[2]: Leaving directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0/ext/fiddle'
make[1]: *** [ext/fiddle/all] Error 2
make[1]: Leaving directory `/tmp/ruby-build.20141225215042.17047/ruby-2.2.0'
make: *** [build-ext] Error 2
hsbt commented 9 years ago

Please install libffi-dev via apt-get or use '--enabled-shared' option

endgame commented 9 years ago

Thank you, this fixes it for me.

jlecour commented 9 years ago

Same issue with Debian 7 ; libffi-dev was missing.

hsbt commented 9 years ago

I added this issue into FAQ: https://github.com/sstephenson/ruby-build/wiki#build-failure-of-fiddle-with-ruby-220

mislav commented 9 years ago

@hsbt Can you add these packages to "suggested build environment" on the top? That would help people who paste these instructions prior to installing Ruby versions on their respective systems.

hsbt commented 9 years ago

@mislav done! Thanks for your advice.

ainslied commented 9 years ago

Hi, I'm using Debian jessie. I cannot find this package :

sudo apt-get install libffi-dev E: Package 'libffi-dev' has no installation candidate

sudo apt-get update; apt-cache search libffi libffi6 - Bibliothèque d'exécution de l'interface de fonction étrangère (FFI)

with Debian Wheezy (in an other server), I get more, do you know why? My source.list seems well configured.. sudo apt-get update; apt-cache search libffi ffindex-dbg - simple index/database for huge amounts of small files (debug) libffindex0 - library for simple index/database for huge amounts of small files libffindex0-dev - library for simple index/database for huge amounts of small files (development) libjffi-java - Java Foreign Function Interface libjffi-jni - Java Foreign Function Interface (JNI library) lib32ffi-dev - Foreign Function Interface library (development files, 32bit) libffi-dev - Foreign Function Interface library (development files) libffi5-dbg - Foreign Function Interface library runtime (debug symbols) libffi-ruby - Transitional package for ruby-ffi libffi-ruby1.8 - Transitional package for ruby-ffi libffi-ruby1.9.1 - Transitional package for ruby-ffi ruby-ffi - load dynamic libraries, bind functions from within ruby code libffi5 - Bibliothèque d'exécution de l'interface de fonction étrangère (FFI) libbfio-dbg - Library to provide basic input/output abstraction (debug)

ainslied commented 9 years ago

Sorry, my /etc/apt/preferences was not empty

zachad commented 9 years ago

Same goes for CentOS 6.x where you'll need to yum install libffi-devel

GCorbel commented 9 years ago

sudo apt-get install libffi-dev workd for me on Linux Mint 17.1. Thanks!

ryanburnette commented 9 years ago

I'm having this exact issue on Ubuntu 14.04.1 LTS but I have libffi-dev installed. Posted as a question on Stack Oveflow in case anyone has any insight.

raulgobr commented 9 years ago

same here with 14.04.1 LTS. I have the libffi-dev.

gnodiah commented 9 years ago

sovled after installed libffi-dev, thanks

kirylrb commented 9 years ago

Have same issue on Ubuntu 15.04 Alpha

$ RUBY_CONFIGURE_OPTS=--enable-shared rbenv install 2.2.0
Downloading ruby-2.2.0.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/7671e394abfb5d262fbcd3b27a71bf78737c7e9347fa21c39e58b0bb9c4840fc
Installing ruby-2.2.0...

BUILD FAILED (Ubuntu 15.04 using ruby-build 20150116-6-g7f1d8df)

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

Last 10 log lines:
    from /tmp/ruby-build.20150122215659.9399/ruby-2.2.0/lib/rubygems.rb:556:in `install'
    from ./tool/rbinstall.rb:717:in `block (2 levels) in <main>'
    from ./tool/rbinstall.rb:716:in `each'
    from ./tool/rbinstall.rb:716:in `block in <main>'
    from ./tool/rbinstall.rb:749:in `call'
    from ./tool/rbinstall.rb:749:in `block in <main>'
    from ./tool/rbinstall.rb:746:in `each'
    from ./tool/rbinstall.rb:746:in `<main>'
uncommon.mk:244: recipe for target 'do-install-all' failed
make: *** [do-install-all] Error 1
davidcpell commented 9 years ago

I am on 14.04.1 LTS and successfully installed 2.2 with rbenv install 2.2.0 after first running sudo apt-get install libffi-dev

ryanburnette commented 9 years ago

A guy on my SO issue said that he fixed it by setting CFLAG to CFLAG=-fPIC.

ghost commented 9 years ago

I also had the same issue with 14.04. LTS. Solved after installing libffi-dev.

hsbt commented 9 years ago

@ryanburnette We(ruby-core) added -fPIC option for next release of Ruby 2.2 :bow:

ajahongir commented 9 years ago

:+1:

ryanburnette commented 9 years ago

👏

njia commented 9 years ago

I had same problem, install libffi did not work but after I installed gcc using linuxbrew the ruby 2.2.0 installed successfully but installing gcc took 70 minutes on my VM.

thebucknerlife commented 9 years ago

installing sudo apt-get install libffi-dev worked for me!

hsbt commented 9 years ago

We released Ruby 2.2.1 with fixing bundled ffi problem. Please try it.

naskoblg commented 9 years ago

I have same issue with Ruby 2.2.1 on FreeBSD 9.3-STABLE amd64

I was able to fix it using:

- /etc/make.conf
CC=clang
CXX=clang++
CPP=clang-cpp
CFLAG=-fPIC
- export
$ CFLAG=-fPIC
$ export CFLAG
$ RUBY_CONFIGURE_OPTS=--enable-shared
$ export RUBY_CONFIGURE_OPTS

Then build:

$ rbenv install 2.2.1
Downloading ruby-2.2.1.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/5a4de38068eca8919cb087d338c0c2e3d72c9382c804fb27ab746e6c7819ab28
Installing ruby-2.2.1...
Installed ruby-2.2.1 to /home/dev/.rbenv/versions/2.2.1
hsbt commented 9 years ago

@naskoblg We already fixed FreeBSD issue with upstream. see https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/49957

aried3r commented 9 years ago

@hsbt, so from what I've gathered, I do not have to manually install libffi-dev anymore with 2.2.1, right? Because I tried with 2.2.1 and still get the following when not installing libffi-dev

linking shared-object fiddle.so
/usr/bin/ld: ./libffi-3.2.1/.libs/libffi.a(raw_api.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
./libffi-3.2.1/.libs/libffi.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [../../.ext/x86_64-linux/fiddle.so] Error 1
make[2]: Leaving directory `/tmp/ruby-build.20150319171236.15537/ruby-2.2.1/ext/fiddle'
make[1]: *** [ext/fiddle/all] Error 2

The error message suggests, as @naskoblg already verified, that adding -fPIC to the compiler flags works. I'll see how I can do that, since I'm using rbenv via chef on Ubuntu Server 14.04 LTS

manuelmeurer commented 9 years ago

Installing libffi-dev fixed this for me. (Ruby 2.2.1, Ubuntu 14.04)

kulbida commented 9 years ago

Installing libffi-dev didn't help to install ruby 2.2.1 on my Debian 7. However installing with --enabled-shared option activated helped. Thanks.

rilian commented 9 years ago

thanks, sudo apt-get install libffi-dev helped on Ubuntu 14.04.1 LTS to rbenv install 2.2.1 :heart_eyes:

FabFab commented 9 years ago

on Amazon Linux 2014.09, same as @zachad for Centos, of course.

yum install libffi-devel
hsbt commented 9 years ago

Hi all. Please try to Ruby 2.2.2

aried3r commented 9 years ago

Hi all. Please try to Ruby 2.2.2

Works for me, thanks!

hsbt commented 9 years ago

@aried3r :+1: Thanks for your feedback

lifehome commented 9 years ago

After installing the libffi-devel-3.0.13-11.el7.x86_64 on Centos 7, it still fails to install Ruby 2.2.2...
Any idea?

UPDATE: installed after sudo -ing all the installation thing, but this is not good for long-term solution, right?

wtgee commented 9 years ago

Having this issue with all 2.x. libffi-dev is installed.

$ RUBY_CONFIGURE_OPTS=--enable-shared
$ rbenv install 2.2.2
Downloading ruby-2.2.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz
error: failed to download ruby-2.2.2.tar.gz

BUILD FAILED (LinuxMint 17.2 using ruby-build 20150803)
wtgee commented 9 years ago

After fiddling around a whole bunch, I found some errors in the logs related to certificates. This answer by Scott Emmons here (not the "correct" solution on that page but the second one down) fixed my problem.

lakesare commented 8 years ago

Thank you, helped for Ubuntu 15.10 with Ruby 2.2.1.

Markmwaura commented 8 years ago

installing sudo apt-get install libffi-dev worked for me on ubuntu 14.04.1. Thanks!

nathanjo commented 7 years ago

For AWS, after running yum install libffi-devel still issue occured, and need to execute yum install gcc and its fixed the issue.