can't setup ruby environment - installing fii gem error - ruby

I'm trying to setup environtment for ruby project.
But when I run 'bundle', I have error during installing 'fii' gem:
Installing ffi (1.8.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/bmalets/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for ffi.h... *** 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.
/Users/bmalets/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
Gem files will remain installed in /Users/bmalets/.rvm/gems/ruby-1.9.3-p448#api2/gems/ffi-1.8.1 for inspection.
Results logged to /Users/bmalets/.rvm/gems/ruby-1.9.3-p448#api2/gems/ffi-1.8.1/ext/ffi_c/gem_make.out
An error occurred while installing ffi (1.8.1), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.8.1'` succeeds before bundling.
My environment:
OS_X 10.8.4
ruby 1.9.3p448
Xcode 4.6.3
libffi-3.0.13
Please, help me to fix it.

Make sure that you have installed Apple Xcode and Command Line Tools (look at this screenshot):
https://developer.apple.com/technologies/tools/
After that, don't forget to install libffi.
1) if you are using homebrew
brew install libffi
2) if you are using macport
sudo port install libffi

Related

Cannot install Jekyll after updating to Catalina - An error occurred while installing ffi (1.9.18)

I have updated my mac to use Catalina and now I am having all sorts of issues when I try and install Jekyll.
This is what I get when I run my usual grunt setup:
Running "jekyll:dist" (jekyll) task
>> Error: Command failed: bundle exec jekyll -v
>> bundler: command not found: jekyll
>> Install missing gem executables with `bundle install`
Warning: Please install Jekyll before running this task. Use --force to continue.
I then run sudo bundle install
I then get this:
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this
application for all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/.........
Using public_suffix 3.0.1
Using addressable 2.5.2
Using bundler 2.1.4
Using colorator 1.1.0
Fetching ffi 1.9.18
Installing ffi 1.9.18 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Applications/MAMP/htdocs/hangr/vendor/bundle/ruby/2.6.0/gems/ffi-1.9.18/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20201016-30905-1yh2cx1.rb extconf.rb
checking for ffi_call() in -lffi... yes
checking for ffi_prep_closure()... 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: /Applications/MAMP/htdocs/hangr/vendor/bundle/ruby/2.6.0/gems/ffi-1.9.18/ext/ffi_c
make "DESTDIR=" clean
current directory: /Applications/MAMP/htdocs/hangr/vendor/bundle/ruby/2.6.0/gems/ffi-1.9.18/ext/ffi_c
make "DESTDIR="
compiling AbstractMemory.c
compiling ArrayType.c
compiling Buffer.c
compiling Call.c
Call.c:355: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
^
1 error generated.
make: *** [Call.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Applications/MAMP/htdocs/hangr/vendor/bundle/ruby/2.6.0/gems/ffi-1.9.18 for inspection.
Results logged to
/Applications/MAMP/htdocs/hangr/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.9.18/gem_make.out
An error occurred while installing ffi (1.9.18), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.18' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
jekyll was resolved to 3.4.3, which depends on
jekyll-sass-converter was resolved to 1.5.1, 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
When I run
ruby -v
I get
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
I have no idea at all what I need to do.
When I run
jekyll -v
I get
-bash: /usr/local/bin/jekyll: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
I tried running this from another post but had no luck
gem install ffi -v '1.9.18' -- --with-cflags="-Wno-error=implicit-function-declaration"
Does anyone have any ideas?
Thanks
The root problem is that you cannot install one of jekyl's dependancies - specifically the ffi gem. Knowing that will better help you workout a fix.
You can see that this is the error by reading your bundle output. Learn how to read these so you can better help yourself in the future; If you were searching for "install ffi on macOS" you might have found more information available to you.
Give that you've just installed Catalina, it's likely that GCC isn't on your machine, or is outdated, or is unlinked.
Try running xcode-select --install to (re)install the Xcode command line tools.
ALSO - STOP USING SUDO
At the very top of your bundle output is a warning that you shouldn't use sudo when installing gems. It's good advice to follow!
Even better advice would be to use rbenv or rvm to create gem sets or environments for each ruby application you're working with. But, if you don't go all the way down that path, ** at least, stop using sudo**

Ruby: Having correct DevKit and Ruby version - Failed to build gem native extension

I installed 1.9.3 ruby from http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-1.9.3-p448.exe to C:\Ruby193.
I downloaded https://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe to C:\ruby_dev_kit and from there ran ruby dk.rb init then ruby dk.rb install
It all installed successfully.
Then when I ran gem install json I keep getting
Installing json (1.4.6) The system cannot find the path specified.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
checking for ruby/re.h... yes
checking for ruby/encoding.h... yes
creating Makefile
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.4.
6 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.4.6/ext/json/ext/ge
nerator/gem_make.out
An error occurred while installing json (1.4.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.4.6'` succeeds before bundling.
I also tried gem install json --platform=ruby
Doesn't change anything. It seems that there's c compiler issues but I path defined correctly and DevKit associated as well.
Tried uninstall and install, doesn't help. Any thoughts?

Why isn't Nokogiri installing?

I'm having trouble installing Nokogiri. When I run bundle install or gem install nokogiri the installation fails.
The error I'm getting is:
(Note: This failure is from using the installation command on nokogiri.org)
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/roneesh/.rbenv/versions/1.9.3-p194/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28/ --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Extracting libxml2-2.8.0.tar.gz into tmp//ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp//ports/libxml2/2.8.0/configure.log' to see what happened.
*** 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.
The command I'm trying to use is:
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28/ --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
I have installed xml2, xslt and libiconv all with brew, and put in their proper versions above. Still no resolution. The only thing I haven't done is libiconv from source (my wget command isn't working for some reason).
You need to specify nokogiri to use the system libraries instead, so it doesn't try to build them itself.
NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install
Answer found here: Error installing nokogiri 1.6.0 on mac (libxml2).
Setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 also did the trick for me, but I had to install the native libraries the gem depends on first (I did it with Homebrew) and then tell the gem to use them.
Summarising:
If previously installed, uninstall the gem:
$ gem uninstall nokogiri
Use Homebrew to install libxml2, libxslt and libiconv:
$ brew install libxml2 libxslt libiconv
Install the gem specifying the paths to the libraries to be linked against:
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"

Can't Install Eventmachine On Synology DiskStation With OpenSSL

I'm trying to install the EventMachine ruby gem on my Synology DiskStation DS211 Linux-based NAS, but the installation fails while trying to create the Makefile for the native extension, saying:
> gem install eventmachine --pre
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/opt/bin/ruby extconf.rb
checking for main() in -lssl... *** 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.
The contents of mkmf.log:
package configuration for openssl is not found
Ruby and OpenSSL were both installed successfully on the machine using Optware ipkg to the default /opt directory.
I suspect that EventMachine fails due to OpenSSL being installed in an unexpected directory, but it is unclear which combination of configuration options and values are necessary to specify the correct location.
Some environment details:
> ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [arm-linux-eabi]
> openssl version
OpenSSL 0.9.8p 16 Nov 2010
> which openssl
/opt/bin/openssl
Has anyone else had any luck installing EventMachine in this environment?
You need install openssl-dev package:
ipkg install openssl-dev
openssl-dev contains package configuration(openssl.pc) and header files.

Problem install do_sqlite3 for DataMapper

sudo env ARCHFLAGS="-arch x86_64" gem install do_sqlite3
Building native extensions. This could take a while...
ERROR: Error installing do_sqlite3:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_open() in -lsqlite3... 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.
I have sqlite3-ruby installed as well as the header files, but for some reason it fails when checking for sqlite3_open()
I am having the same issue:
sudo env ARCHFLAGS="-arch x86_64" gem install do_sqlite3
Building native extensions. This could take a while...
ERROR: Error installing do_sqlite3:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/do_sqlite3-0.10.1.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/do_sqlite3-0.10.1.1/ext/do_sqlite3/gem_make.out
I am running Snow Leopard. I'm not sure about previous installations of sqlite3 but I did try this:
port search sqlite
And it returned the following (among others):
...
sqlite3 #3.6.17 (databases)
an embedded SQL database engine
To be honest I'm not sure what all this means. What would anyone suggest for getting do_sqlite3 installed for use in Rails 3 with DataMapper? (Also, running it without the 'env ARCHFLAGS="-arch x86_64"' gives the same errors.)
Ok, first question is why are you passing the ARCHFLAGS? That should not be necessary, if it also doesn't work without passing them, what is the output you get then?
Next question is what version of sqlite3 is it picking up? Do you have sqlite3 installed through Macports for example? Did you upgrade to Snow Leopard recently and still have an sqlite3 install from before upgrading?

Resources