ruby / fiddle

A libffi wrapper for Ruby.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation of fiddle failing on Ruby 2.7.3

junaruga opened this issue · comments

I failed to install fiddle 1.0.9 on Ruby 2.7.3 built from source. Here is the full log.

$ cat /etc/fedora-release 
Fedora release 34 (Thirty Four)

$ gcc --version
gcc (GCC) 11.1.1 20210531 (Red Hat 11.1.1-3)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ which ruby
/usr/local/ruby-2.7.3/bin/ruby

$ ruby -v
ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-linux]

$ gem install --no-document fiddle --user
Fetching fiddle-1.0.9.gem
Building native extensions. This could take a while...
ERROR:  Error installing fiddle:
	ERROR: Failed to build gem native extension.

    current directory: /home/jaruga/.gem/ruby/2.7.0/gems/fiddle-1.0.9/ext/fiddle
/usr/local/ruby-2.7.3/bin/ruby -I /usr/local/ruby-2.7.3/lib/ruby/2.7.0 -r ./siteconf20210704-791519-1jr4m15.rb extconf.rb
checking for --enable-debug-build option... no
checking for ffi.h... yes
...
checking for ruby/memory_view.h... yes
checking for rb_memory_view_t in ruby/memory_view.h... no
creating Makefile

current directory: /home/jaruga/.gem/ruby/2.7.0/gems/fiddle-1.0.9/ext/fiddle
make "DESTDIR=" clean

current directory: /home/jaruga/.gem/ruby/2.7.0/gems/fiddle-1.0.9/ext/fiddle
make "DESTDIR="
compiling closure.c
compiling conversions.c
compiling fiddle.c
compiling function.c
compiling handle.c
compiling memory_view.c
In file included from memory_view.c:6:
/usr/include/ruby/memory_view.h: In function ‘RBIMPL_ATTR_PURE’:
/usr/include/ruby/memory_view.h:125:1: error: expected declaration specifiers before ‘RBIMPL_ATTR_PURE’
  125 | RBIMPL_ATTR_PURE()
      | ^~~~~~~~~~~~~~~~
...
make: *** [Makefile:246: memory_view.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/jaruga/.gem/ruby/2.7.0/gems/fiddle-1.0.9 for inspection.
Results logged to /home/jaruga/.gem/ruby/2.7.0/extensions/x86_64-linux/2.7.0/fiddle-1.0.9/gem_make.out

It seems the fiddle trying to find the memory_view.h file. But I could not find the header file on Ruby 2.7.3. Seeing the ruby/ruby, the header file is created by ruby/ruby#3261 in 2020.

$ find /usr/local/ruby-2.7.3/ -name memory_view.h

The header file exists on Ruby 3.0.1 And On Ruby 3.0.1, The installation of the fiddle succeeds.

$ find /usr/local/ruby-3.0.1/ -name memory_view.h
/usr/local/ruby-3.0.1/include/ruby-3.0.0/ruby/memory_view.h

Thanks.
We could't use have_header("ruby/memory_view.h") because it may find ruby/memory_view.h installed in /usr/include/.

Thanks! Ah right. The fiddle installed in Ruby (/usr/local/ruby-2.7.3/bin/ruby) was checking the system Ruby (3.0.1)'s header /usr/include/ruby/memory_view.h!

$ /usr/bin/ruby -v
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]

$ find /usr/include/ -name memory_view.h
/usr/include/ruby/memory_view.h

Hey, I have same problem but I am using asdf for tool versioning in my vps, in my local dev same method using asdf as tool versioning is no problem. I don't know how to solve this..

Updating fiddle
Fetching fiddle-1.1.1.gem
Building native extensions. This could take a while...
ERROR:  Error installing fiddle:
        ERROR: Failed to build gem native extension.

    current directory: /root/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/fiddle-1.1.1/ext/fiddle
/root/.asdf/installs/ruby/3.1.3/bin/ruby -I /root/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0 extconf.rb
checking for --enable-debug-build option... no
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
        --without-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=/root/.asdf/installs/ruby/3.1.3/bin/$(RUBY_BASE_NAME)
        --enable-debug-build
        --disable-debug-build
        --with-libffi-source-dir
        --without-libffi-source-dir
        --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:73:in `<main>': missing libffi. Please install libffi or use --with-libffi-source-dir with libffi source location. (RuntimeError)

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

  /root/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/fiddle-1.1.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /root/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/fiddle-1.1.1 for inspection.
Results logged to /root/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/fiddle-1.1.1/gem_make.out

OS version (local) : Windows 11 22H2 ( for dev using WSL Linux Ubuntu 20.04 LTS)
tool versioning (vps) : asdf
tool versioning (local) : asdf
OS version (VPS) : Linux Ubuntu 20.04
asdf (VPS) using Ruby (3.1.3)
asdf (Local) using Ruby (3.1.3)

Hey, I have same problem but I am using asdf for tool versioning in my vps, in my local dev same method using asdf as tool versioning is no problem. I don't know how to solve this..

Updating fiddle
Fetching fiddle-1.1.1.gem
Building native extensions. This could take a while...
ERROR:  Error installing fiddle:
        ERROR: Failed to build gem native extension.

    current directory: /root/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/fiddle-1.1.1/ext/fiddle
/root/.asdf/installs/ruby/3.1.3/bin/ruby -I /root/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0 extconf.rb
checking for --enable-debug-build option... no
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
        --without-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=/root/.asdf/installs/ruby/3.1.3/bin/$(RUBY_BASE_NAME)
        --enable-debug-build
        --disable-debug-build
        --with-libffi-source-dir
        --without-libffi-source-dir
        --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:73:in `<main>': missing libffi. Please install libffi or use --with-libffi-source-dir with libffi source location. (RuntimeError)

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

  /root/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/fiddle-1.1.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /root/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/fiddle-1.1.1 for inspection.
Results logged to /root/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/fiddle-1.1.1/gem_make.out

OS version (local) : Windows 11 22H2 ( for dev using WSL Linux Ubuntu 20.04 LTS) tool versioning (vps) : asdf tool versioning (local) : asdf OS version (VPS) : Linux Ubuntu 20.04 asdf (VPS) using Ruby (3.1.3) asdf (Local) using Ruby (3.1.3)

done solved, tks