ruby / fiddle

A libffi wrapper for Ruby.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERROR: Failed to build gem native extension.

darkRaspberry opened this issue · comments

Problem

I'm hated the fact that default Linux package distributor don't update the package quickly enough. So is the case for RUBY. Then I came to think why not kill this problem with Homebrew . And I installed Ruby with Brew which works nice. Not a problem. But recently I got update of RUBY 3.0.0 and problem starts. With the fact I use Ruby with brew. The fiddle need a dependency called ffi and ffi is also served by apt. I don't know much but the problem is ffi.

Expected

The gem should be normally installed without any issue.

Actual

user@machine:~$ gem update
Updating installed gems
Updating fiddle
Building native extensions. This could take a while...
ERROR:  Error installing fiddle:
	ERROR: Failed to build gem native extension.

    current directory: /home/linuxbrew/.linuxbrew/lib/ruby/gems/3.0.0/gems/fiddle-1.0.7/ext/fiddle
/home/linuxbrew/.linuxbrew/opt/ruby/bin/ruby -I /home/linuxbrew/.linuxbrew/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0 -r ./siteconf20210104-8354-iij1al.rb extconf.rb
checking for ffi.h... no
checking for ffi/ffi.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/home/linuxbrew/.linuxbrew/Cellar/ruby/3.0.0_1/bin/$(RUBY_BASE_NAME)
	--enable-bundled-libffi
	--disable-bundled-libffi
	--with-libffi-dir
	--without-libffi-dir
	--with-libffi-include
	--without-libffi-include=${libffi-dir}/include
	--with-libffi-lib
	--without-libffi-lib=${libffi-dir}/lib
	--with-libffi-config
	--without-libffi-config
	--with-pkg-config
	--without-pkg-config
	--with-ffi-dir
	--without-ffi-dir
	--with-ffi-include
	--without-ffi-include=${ffi-dir}/include
	--with-ffi-lib
	--without-ffi-lib=${ffi-dir}/lib
extconf.rb:46:in `<main>': missing libffi. Please install libffi. (RuntimeError)

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/linuxbrew/.linuxbrew/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/fiddle-1.0.7/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/linuxbrew/.linuxbrew/lib/ruby/gems/3.0.0/gems/fiddle-1.0.7 for inspection.
Results logged to /home/linuxbrew/.linuxbrew/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/fiddle-1.0.7/gem_make.out
Gems updated: fiddle

What to do now?
mkmf.log
gem_make.out.log rename due to upload issue.

After installing 2 packages everything works.

user@machine:~$ gem install ffi
Fetching ffi-1.14.2.gem
Building native extensions. This could take a while...
Successfully installed ffi-1.14.2
Parsing documentation for ffi-1.14.2
Installing ri documentation for ffi-1.14.2
Done installing documentation for ffi after 7 seconds
1 gem installed
user@machine:~$ sudo apt install libffi-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  libffi-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 57.5 kB of archives.
After this operation, 314 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu groovy/main amd64 libffi-dev amd64 3.4~20200819gead65ca871-0ubuntu3 [57.5 kB]
Fetched 57.5 kB in 0s (130 kB/s)      
Selecting previously unselected package libffi-dev:amd64.
(Reading database ... 206718 files and directories currently installed.)
Preparing to unpack .../libffi-dev_3.4~20200819gead65ca871-0ubuntu3_amd64.deb ...
Unpacking libffi-dev:amd64 (3.4~20200819gead65ca871-0ubuntu3) ...
Setting up libffi-dev:amd64 (3.4~20200819gead65ca871-0ubuntu3) ...
Processing triggers for install-info (6.7.0.dfsg.2-5) ...
Processing triggers for man-db (2.9.3-2) ...

And the gem is now updated.

user@machine:~$ gem update
Updating installed gems
Updating fiddle
Building native extensions. This could take a while...
Successfully installed fiddle-1.0.7
Parsing documentation for fiddle-1.0.7
Installing ri documentation for fiddle-1.0.7
Installing darkfish documentation for fiddle-1.0.7
Done installing documentation for fiddle after 1 seconds
Parsing documentation for fiddle-1.0.7
Done installing documentation for fiddle after 0 seconds
Gems updated: fiddle

In my understanding the ffi gem does nothing and the apt package libffi-dev is necessary for this issue.
Thanks for everything you guys done on this fiddle. You can close this issue, or add this in documentation.

As the error message said, you should have to install libffi-dev by apt:

"extconf.rb:46:in** `<main>': missing libffi. Please install libffi. (RuntimeError)