Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't install ffi gem - MacOS Big Sur 11.0.1

I'm trying this Jekyll theme

And I referenced this docs

And This error code occurs endless!!

Why this error occurs?

Ah, For your information, I proceeded this & this

Even if I search error message, the data doesn't come out well!

I've been doing this all day, and I thought I can't cover this problem yet.

Can you help me? If you need any information in the comments, I'll make up for it quickly.

And this is my error code:

swsui-MacBook-Pro:flexton-master sws$ bundle exec jekyll serve
Traceback (most recent call last):
    2: from /Users/sws/.gem/ruby/2.7.0/bin/bundle:23:in `<main>'
    1: from /Users/sws/.rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
/Users/sws/.rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': Could not find 'bundler' (1.16.0.pre.3) required by your /Users/sws/Developer/blog/flexton-master/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.16.0.pre.3`
swsui-MacBook-Pro:flexton-master sws$ bundle update --bundler
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/.........
Using public_suffix 3.0.2
Using addressable 2.5.2
Using bundler 2.1.4
Using colorator 1.1.0
Using concurrent-ruby 1.0.5
Using eventmachine 1.2.5
Using http_parser.rb 0.6.0
Using em-websocket 0.5.1
Fetching ffi 1.9.23
Installing ffi 1.9.23 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/sws/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/ffi-1.9.23/ext/ffi_c
/Users/sws/.rbenv/versions/2.7.2/bin/ruby -I /Users/sws/.rbenv/versions/2.7.2/lib/ruby/2.7.0 -r ./siteconf20201122-4218-1dxgm86.rb
extconf.rb
checking for ffi_call() in -lffi... yes
checking for ffi_closure_alloc()... yes
checking for ffi_raw_call()... yes
checking for ffi_prep_raw_closure()... yes
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... yes
creating extconf.h
creating Makefile

current directory: /Users/sws/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/ffi-1.9.23/ext/ffi_c
make "DESTDIR=" clean

current directory: /Users/sws/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/ffi-1.9.23/ext/ffi_c
make "DESTDIR="
compiling AbstractMemory.c
compiling ArrayType.c
compiling Buffer.c
compiling Call.c
Call.c:334:5: error: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
    rbffi_thread_blocking_region(call_blocking_function, data, (void *) -1, NULL);
    ^
./Thread.h:78:39: note: expanded from macro 'rbffi_thread_blocking_region'
# define rbffi_thread_blocking_region rb_thread_call_without_gvl
                                      ^
Call.c:388:20: warning: incompatible pointer types passing 'VALUE (void *)' (aka 'unsigned long (void *)') to parameter of type
'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-pointer-types]
        rb_rescue2(rbffi_do_blocking_call, (VALUE) bc, rbffi_save_frame_exception, (VALUE) &frame, rb_eException, (VALUE) 0);
                   ^~~~~~~~~~~~~~~~~~~~~~
/Users/sws/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1988:25: note: passing argument to parameter here
VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
                        ^
Call.c:388:56: warning: incompatible pointer types passing 'VALUE (void *, VALUE)' (aka 'unsigned long (void *, unsigned long)') to
parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long)') [-Wincompatible-pointer-types]
        rb_rescue2(rbffi_do_blocking_call, (VALUE) bc, rbffi_save_frame_exception, (VALUE) &frame, rb_eException, (VALUE) 0);
                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/sws/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1988:47: note: passing argument to parameter here
VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
                                              ^
2 warnings and 1 error generated.
make: *** [Call.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/sws/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/ffi-1.9.23 for inspection.
Results logged to /Users/sws/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-20/2.7.0/ffi-1.9.23/gem_make.out

An error occurred while installing ffi (1.9.23), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.23' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  jekyll was resolved to 3.7.3, which depends on
    jekyll-sass-converter was resolved to 1.5.2, which depends on
      sass was resolved to 3.5.5, which depends on
        sass-listen was resolved to 4.0.0, which depends on
          rb-inotify was resolved to 0.9.10, which depends on
            ffi

And this is my environment (MacOS Big Sur 11.0.1)

swsui-MacBook-Pro:flexton-master sws$ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
swsui-MacBook-Pro:flexton-master sws$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20201118)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
swsui-MacBook-Pro:flexton-master sws$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.1.4
  - RUBY VERSION: 2.7.2 (2020-10-01 patchlevel 137) [x86_64-darwin20]
  - INSTALLATION DIRECTORY: /Users/sws/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0
  - USER INSTALLATION DIRECTORY: /Users/sws/.gem/ruby/2.7.0
  - RUBY EXECUTABLE: /Users/sws/.rbenv/versions/2.7.2/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /Users/sws/.rbenv/versions/2.7.2/bin
  - SPEC CACHE DIRECTORY: /Users/sws/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/sws/.rbenv/versions/2.7.2/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-20
  - GEM PATHS:
     - /Users/sws/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0
     - /Users/sws/.gem/ruby/2.7.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/sws/.rbenv/versions/2.7.2/bin
     - /usr/local/Cellar/rbenv/1.1.2/libexec
     - /Users/sws/.gem/ruby/2.7.0/bin
     - /Users/sws/.rbenv/shims
     - /usr/local/opt/ruby/bin
     - %PATH
     - /bin
     - /usr/local/bin
     - /usr/bin

And this is my .bash_profile


# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
# Add Visual Studio Code (code)
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"

export PATH=%PATH:/bin:/usr/local/bin:/usr/bin

export PATH="/usr/local/opt/ruby/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.gem/ruby/2.7.0/bin:$PATH"
like image 649
learner Avatar asked Nov 22 '20 12:11

learner


3 Answers

Have you tried this?

bundle config build.ffi -- --with-cflags=-Wno-implicit-function-declaration

Clang now reports an error when you use a function without an explicit declaration when building C or Objective-C code for macOS (-Werror=implicit-function-declaration flag is on). This additional error detection unifies Clang’s behavior for iOS/tvOS and macOS 64-bit targets for this diagnostic. (49917738)

refs:

  • https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes
  • https://github.com/ffi/ffi/issues/840
  • https://github.com/tmm1/rbtrace/issues/81
like image 131
Jorge Vargas Avatar answered Nov 07 '22 07:11

Jorge Vargas


ffi -v 1.14.0 should fix Mac M1 compatibility issues.

Ref: https://github.com/ffi/ffi/blob/master/CHANGELOG.md#1140--2020-12-18

I tested this on my machine which runs Big Sur 11.2.

like image 9
Petr Gazarov Avatar answered Nov 07 '22 08:11

Petr Gazarov


optflags="-Wno-error=implicit-function-declaration" LDFLAGS="-L/opt/homebrew/opt/libffi/lib" CPPFLAGS="-I/opt/homebrew/opt/libffi/include" PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig" gem install ffi -v '1.10.0'

via https://github.com/ffi/ffi/issues/651#issuecomment-434973801

like image 3
Ilias Karim Avatar answered Nov 07 '22 08:11

Ilias Karim