I'm having troubles to do bundle install in one project I get to work on in Rails 4.2.10. When I bundle I receive the next error:
An error occurred while installing ffi (1.9.25), and Bundler cannot continue.
Make sure that gem install ffi -v '1.9.25' succeeds before bundling.
In Gemfile:
s3_direct_upload was resolved to 0.1.6, which depends on
sass-rails was resolved to 5.0.7, which depends on
sass was resolved to 3.6.0, 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
When I run gem install ffi -v '1.9.25' also an error occurs:
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
current directory: /xxx/xxx/.rvm/gems/ruby-2.5.3/gems/ffi-1.9.25/ext/ffi_c
/xxx/xxx/.rvm/rubies/ruby-2.5.3/bin/ruby -r ./siteconf20190110-6923-1jimorr.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... yes
checking for ffi_call() in -lffi... yes
checking for ffi_closure_alloc()... no
checking for ffi_raw_call()... no
checking for shlwapi.h... no
checking for ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile
current directory: /xxx/xxx/.rvm/gems/ruby-2.5.3/gems/ffi-1.9.25/ext/ffi_c
make "DESTDIR=" clean
current directory: /xxx/xxx/.rvm/gems/ruby-2.5.3/gems/ffi-1.9.25/ext/ffi_c
make "DESTDIR="
Configuring libffi
clang: error: unsupported option '-print-multi-os-directory'
clang: error: no input files
cd "/xxx/xxx/.rvm/gems/ruby-2.5.3/gems/ffi-1.9.25/ext/ffi_c/libffi-x86_64-darwin18" && /Volumes/Macintosh HD/Applications/Xcode.app/Contents/Developer/usr/bin/make
/bin/sh: /Volumes/Macintosh: No such file or directory
make: *** ["/xxx/xxx/.rvm/gems/ruby-2.5.3/gems/ffi-1.9.25/ext/ffi_c/libffi-x86_64-darwin18"/.libs/libffi_convenience.a] Error 127
make failed, exit code 2
Gem files will remain installed in /xxx/xxx/.rvm/gems/ruby-2.5.3/gems/ffi-1.9.25 for inspection.
Results logged to /xxx/xxx/.rvm/gems/ruby-2.5.3/extensions/x86_64-darwin-18/2.5.0/ffi-1.9.25/gem_make.out
I've been trying many solutions online but cannot resolve this issue.
Seems the issue is with my system as I'm new to the team and the other developers were unable to help me as they do not have this kind of issue.
I was able to successfully install ffi with the following command:
LDFLAGS="-L/usr/local/opt/libffi/lib" PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig" gem install ffi -v '1.9.25'
Found on some japanese board
According to the libffi README, only GCC is a tested compiler on macOS. You are using Clang, which doesn't support the command line option -print-multi-os-directory.
You need to either patch libffi to work with Clang, or use GCC.
Your error is the following Configuring libffi
clang: error: unsupported option '-print-multi-os-directory'
clang: error: no input files because Clang (wich is the C compiler you are using) doesn't support the option '-print-multi-os-directory'.
Could you check that X-Code command line tools are perfectly installed by executing the following command? xcode-select --install
Also would you mind to try brew install automake autoconf libtool libffi to install required dependencies?
Related
HW: Mac Intel silicon
OS: MacOS Ventura - Version 13.1
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin21]
rails 7.0.2.2
After I installed the MacOS Ventura update, I was getting an error as I was trying to do 'bundle install', and got some errors.
I googled some, and then did the following:
xcode-select --install
When that was finished, I also made sure sure developer tools access to Terminal (through the settings UI).
I ran bundle install again, same results:
Installing racc 1.6.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/my-mac/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/racc-1.6.1/ext/racc/cparse
/Users/my-mac/.asdf/installs/ruby/3.1.0/bin/ruby -I /Users/my-mac/.asdf/installs/ruby/3.1.0/lib/ruby/3.1.0 -r ./siteconf20230126-46139-whcmb7.rb extconf.rb
checking for rb_block_call()... yes
checking for rb_ary_subseq()... yes
creating Makefile
current directory: /Users/my-mac/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/racc-1.6.1/ext/racc/cparse
make DESTDIR\= clean
current directory: /Users/my-mac/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/racc-1.6.1/ext/racc/cparse
make DESTDIR\=
compiling cparse.c
linking shared-object racc/cparse.bundle
ld: warning: -undefined dynamic_lookup may not work with chained fixups
current directory: /Users/my-mac/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/racc-1.6.1/ext/racc/cparse
make DESTDIR\= install
make: /usr/local/bin/gmkdir: No such file or directory
make: *** [.sitearchdir.-.racc.time] Error 1
make install failed, exit code 2
....
An error occurred while installing racc (1.6.1), and Bundler cannot continue.
In Gemfile:
rails was resolved to 7.0.2.2, which depends on
actioncable was resolved to 7.0.2.2, which depends on
actionpack was resolved to 7.0.2.2, which depends on
actionview was resolved to 7.0.2.2, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri was resolved to 1.13.10, which depends on
racc
bundle install used to work fine. I also checked and I do not have a
/usr/local/bin/gmkdir
or
/opt/local/bin/gmkdir
Any ideas?
That compile process is looking for a gnu version of mkdir with the name ‘gmkdir’. This is an attempt to make the process work on windows.
Since the macOS version of mkdir is probably adequate, you can just create an alias to mkdir called ‘gmkdir’ in /user/local/bin’.
This is a hack until that gem install process is updated to realise that it’s on macOS and doesn’t try to build based on defaults for an unknown OS.
I tried all the suggestions, but none worked. The solution was:
brew link --overwrite coreutils
When I try to install cocoapods on my mac using sudo cmd, i.e "sudo gem install cocoapods".
It shows Failed to build gem native extension.
How to install cocoapods on mac,
xxx-MacMini1 ~ % sudo gem install cocoapods
Password:
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c
/usr/local/opt/ruby#2.7/bin/ruby -I /usr/local/Cellar/ruby#2.7/2.7.5/lib/ruby/2.7.0 -r ./siteconf20220318-18160-1id5gxj.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ffi... yes
checking for ffi_prep_closure_loc() in -lffi... yes
checking for ffi_prep_cif_var()... yes
checking for ffi_raw_call()... yes
checking for ffi_prep_raw_closure()... yes
checking for whether -pthread is accepted as LDFLAGS... yes
creating extconf.h
creating Makefile
current directory: /usr/local/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c
make DESTDIR\= clean
current directory: /usr/local/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c
make DESTDIR\=
compiling AbstractMemory.c
compiling ArrayType.c
compiling Buffer.c
compiling Call.c
compiling ClosurePool.c
compiling DynamicLibrary.c
compiling Function.c
Function.c:867:17: error: implicit declaration of function 'ffi_prep_closure_loc' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ffiStatus = ffi_prep_closure_loc(closure->pcl, &fnInfo->ffi_cif, callback_invoke, closure, code);
^
Function.c:867:17: note: did you mean 'ffi_prep_closure'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi/ffi.h:269:1: note: 'ffi_prep_closure' declared here
ffi_prep_closure(
^
1 error generated.
make: *** [Function.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/lib/ruby/gems/2.7.0/gems/ffi-1.15.5 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/ffi-1.15.5/gem_make.out
How do I fix this issue?
Looks like you have a Ruby issue. Try installing version 2.6.3 using:
sudo gem install cocoapods -v 2.6.3
and then try to run sudo gem install cocoapods. If this didn't work, try the following:
Open terminal and run
curl -L https://get.rvm.io | bash -s stable
Then
rvm install ruby-2.6
This would install the ruby for you if its not yet installed. After this just update ruby to the new version using
rvm use ruby-2.6.3
Make ruby 2.6.3 your default
rvm --default use 2.6.3
Then hopefully you can run
sudo gem install cocoapods
Trying to deploy Rails app onUbuntu 20 is impossible to install pg, and any attempt to bundle will incur in errors
$ gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /home/user/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3/ext
/home/user/.rvm/rubies/ruby-2.6.1/bin/ruby -I /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210417-119158-37ke72.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQsetSingleRowMode()... yes
checking for PQconninfo()... yes
checking for PQsslAttribute()... yes
checking for PQresultVerboseErrorMessage()... yes
checking for PQencryptPasswordConn()... yes
checking for PQresultMemorySize()... yes
checking for timegm()... yes
checking for rb_gc_adjust_memory_usage()... yes
checking for unistd.h... yes
checking for inttypes.h... yes
checking for C99 variable length arrays... yes
creating extconf.h
creating Makefile
current directory: /home/user/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3/ext
make "DESTDIR=" clean
current directory: /home/user/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3/ext
make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
compiling pg_binary_decoder.c
compiling pg_binary_encoder.c
compiling pg_coder.c
compiling pg_connection.c
compiling pg_copy_coder.c
compiling pg_errors.c
compiling pg_record_coder.c
compiling pg_result.c
compiling pg_text_decoder.c
compiling pg_text_encoder.c
compiling pg_tuple.c
compiling pg_type_map.c
compiling pg_type_map_all_strings.c
compiling pg_type_map_by_class.c
compiling pg_type_map_by_column.c
compiling pg_type_map_by_mri_type.c
compiling pg_type_map_by_oid.c
compiling pg_type_map_in_ruby.c
compiling pg_util.c
linking shared-object pg_ext.so
current directory: /home/user/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3/ext
make "DESTDIR=" install
make: /usr/bin/mkdir: Command not found
make: *** [Makefile:201: .sitearchdir.time] Error 127
make install failed, exit code 2
Gem files will remain installed in /home/user/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3 for inspection.
Results logged to /home/user/.rvm/gems/ruby-2.6.1/extensions/x86_64-linux/2.6.0/pg-1.2.3/gem_make.out
on bundle install nothing seem to work:
An error occurred while installing bcrypt (3.1.16), and Bundler cannot continue.
Make sure that gem install bcrypt -v '3.1.16' --source 'https://rubygems.org/' succeeds before bundling.
In Gemfile:
bcrypt
An error occurred while installing nio4r (2.5.7), and Bundler cannot continue.
Make sure that gem install nio4r -v '2.5.7' --source 'https://rubygems.org/' succeeds before bundling.
In Gemfile:
rails was resolved to 6.1.3.1, which depends on
actioncable was resolved to 6.1.3.1, which depends on
nio4r
An error occurred while installing racc (1.5.2), and Bundler cannot continue.
Make sure that gem install racc -v '1.5.2' --source 'https://rubygems.org/' succeeds before bundling.
Nothing seems to work and there is not useful information on how to solve problem
make: /usr/bin/mkdir: Command not found it's the reason.
Please write this command with sudo perm.
sudo ln -s $(which mkdir) /usr/bin/mkdir
And try again bundle.
This happens because you need install the following packages that the pg gem requires:
sudo apt install postgresql postgresql-contrib libpq-dev
Then configure postgres and verify is running.
ffi gem 1.9.21 installed successfully.
I also tried to run these commands but no success.
sudo apt install libffi-dev
gem inst ffi
This error occurs when I deploy to AWS. The error looks like this.
Installing dotenv 2.2.1
Installing request_store 1.3.2
Installing draper 3.0.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/opt/rubies/ruby-2.2.3/bin/ruby -r ./siteconf20180207-2245-1bjhja4.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
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
creating extconf.h
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
Running autoreconf for libffi
/var/app/ondeck/vendor/bundle/gems/ffi-1.9.21/ext/ffi_c/libffi/autogen.sh: line 2: exec: autoreconf: not found
make: *** ["/var/app/ondeck/vendor/bundle/gems/ffi-1.9.21/ext/ffi_c/libffi-x86_64-linux"/.libs/libffi_convenience.a] Error 127
make failed, exit code 2
Gem files will remain installed in /var/app/ondeck/vendor/bundle/gems/ffi-1.9.21 for inspection.
Results logged to /var/app/ondeck/vendor/bundle/extensions/x86_64-linux/2.2.0-static/ffi-1.9.21/gem_make.out
An error occurred while installing ffi (1.9.21), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.21'` succeeds before bundling. (Executor::NonZeroExitStatus)
Any help will be much appriciated. thanks in advance.
Seems like this issue is due to the ffi latest version, I specified the ffi oldest version in Gemfile gem 'ffi', '1.9.18' run bundle install in the console, it fixed my issue.
As stated in a comment on a relevant issue, the workaround is:
sudo apt install libffi-dev
Do this in your server
sudo apt-get install ruby-dev
Ref: Registered issue
Please let me know If this not worked.
I'm trying to install an old version of nokogiri, but I am having trouble specifying the format:
I'm using
gem install nokogiri -v 1.5.2 -- --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
but this is not the correct syntax. Do you know how to do this?
ERROR
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/boris/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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:
You’ve only specified the lib dir to use, try specifying the include dir as well:
gem install nokogiri -v 1.5.2 -- \
--with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib \
--with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include
You may be able to specify both together:
gem install nokogiri -v 1.5.2 -- \
--with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1
It looks like there was some changes as to how Nokogiri finds iconv between versions 1.5.2 and 1.5.5, which may explain why you’re able to install the latest version but not 1.5.2.
I simply installed homebrew, and used the brew link inconv to create the necessary symlinks to compile the gem.
$brew link libiconv
Linking /usr/local/Cellar/libiconv/1.13.1... 18 symlinks created
$gem install nokogiri -v 1.5.2