Failed to build ruby gem ffi native extension - ruby-on-rails

I've created a base box for Vagrant using VirtualBox and the latest image of Ubuntu server 12.04 LTS.
Installed all updates, build-essential, libffi-dev among others
I've installed rvm and ruby 1.9.3-p484 (this is the required version).
When I try to install the ffi gem via gem install ffi I get:
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p484/bin/ruby 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 rb_thread_blocking_region()... yes
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
make clean
make
compiling Types.c
compiling MethodHandle.c
compiling MappedType.c
compiling Function.c
Function.c: In function ‘callback_invoke’:
Function.c:479:9: warning: passing argument 1 of ‘rb_thread_call_with_gvl’ from incompatible pointer type [enabled by default]
Function.c:102:14: note: expected ‘void * (*)(void *)’ but argument is of type ‘VALUE (*)(void *)’
compiling Struct.c
compiling Type.c
compiling MemoryPointer.c
compiling Pointer.c
compiling DynamicLibrary.c
DynamicLibrary.c: In function ‘library_initialize’:
DynamicLibrary.c:127:23: error: ‘RTLD_LAZY’ undeclared (first use in this function)
DynamicLibrary.c:127:23: note: each undeclared identifier is reported only once for each function it appears in
DynamicLibrary.c: In function ‘rbffi_DynamicLibrary_Init’:
DynamicLibrary.c:327:5: error: ‘RTLD_LAZY’ undeclared (first use in this function)
DynamicLibrary.c:328:5: error: ‘RTLD_NOW’ undeclared (first use in this function)
DynamicLibrary.c:329:5: error: ‘RTLD_GLOBAL’ undeclared (first use in this function)
make: *** [DynamicLibrary.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p484#somegemset/gems/ffi-1.9.3 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p484#somegemset/extensions/x86_64-linux/1.9.1/ffi-1.9.3/gem_make.out
I can't seem to find any information about this error. I'm guessing I'm missing an obvious package, but really not sure what it can be.
Would definitely appreciate any help I can get on this one.

Related

Trouble installing rails on MAC OS X 10.9.2

Having trouble installing rails on mac and wondering if someone could help me:
dannys-mbp-2:~ Danny1$ sudo gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for libkern/OSAtomic.h... yes
creating Makefile
make "DESTDIR=" clean
make
"DESTDIR="
compiling atomic_reference.c
atomic_reference.c:57:59: warning: incompatible pointer types passing 'void **' to parameter of type 'volatile int64_t *' (aka 'volatile long long *') [-Wincompatible-pointer-types]
if (OSAtomicCompareAndSwap64(expect_value, new_value, &DATA_PTR(self))) {
^~~~~~~~~~~~~~~
/usr/include/libkern/OSAtomic.h:507:93: note: passing argument to parameter '__theValue' here
bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue );
^
1 warning generated.
linking shared-object atomic_reference.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [atomic_reference.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.16 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/atomic-1.1.16/gem_make.out
I was dealing with this and finally stumbled upon the Bug report for this. I used the following command and it worked for me:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install rails
Official report: https://bugs.ruby-lang.org/issues/9624

Error installing gem atomic

I tried installing the atomic gem after a bundle error when I ran rails new "app" command. I'm running OS X 10.9.2. I also tried the xcode-select --install command. Here are my results.
> sudo gem install atomic -v '1.1.16'
Building native extensions. This could take a while...
ERROR: Error installing atomic:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for libkern/OSAtomic.h... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling atomic_reference.c
atomic_reference.c:57:59: warning: incompatible pointer types passing 'void **' to parameter of type 'volatile int64_t *' (aka 'volatile long long *') [-Wincompatible-pointer-types]
if (OSAtomicCompareAndSwap64(expect_value, new_value, &DATA_PTR(self))) {
^~~~~~~~~~~~~~~
/usr/include/libkern/OSAtomic.h:507:93: note: passing argument to parameter '__theValue' here
bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue );
^
1 warning generated.
linking shared-object atomic_reference.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [atomic_reference.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.16 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/atomic-1.1.16/gem_make.out
For Installing atomic 1.1.16, you must have JDK8 installed on your system. It is a prerequisite.
However, it is not required after that. Just for installing the gem.
To run the gem, you just need JDK6 or greater.

(Another) error when installing Rails

I am currently trying to install Rails on a new Mac.
I have an error when I try to install the gem "atomic".
I already tried every solutions I found on the net: installing xcode, trying changing the versions of ruby, etc. but it never works.
My config:
OS X 10.9.2
xcode 5.1
ruby 2.0.0p247
gem 2.2.2
when I enter "xcode-select -p", I get:
/Applications/Xcode.app/Contents/Developer
during atomic install, the error is the following:
"ERROR: Error installing atomic:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for libkern/OSAtomic.h... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling atomic_reference.c
atomic_reference.c:57:59: warning: incompatible pointer types passing 'void **' to parameter of type 'volatile int64_t *' (aka 'volatile long long *') [-Wincompatible-pointer-types]
if (OSAtomicCompareAndSwap64(expect_value, new_value, &DATA_PTR(self))) {
^~~~~~~~~~~~~~~
/usr/include/libkern/OSAtomic.h:507:93: note: passing argument to parameter '__theValue' here
bool OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue );
^
1 warning generated.
linking shared-object atomic_reference.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [atomic_reference.bundle] Error 1
make failed, exit code 2"
Don't hesitate to ask for more infos,
Thanks a lot
I would recommend following steps:
Uninstall atomic gem
gem uninstall atomic
Re-Install atomic gem
gem install atomic
Install rails
gem install rails

I can't install the sqlite3 gem on mac osx 10.8.2

My bundle install is not working and I get this error:
Installing sqlite3 (1.3.6) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/Frank/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb --with-sqlite3- include=/Users/Frank/include --with-sqlite3-lib=/Users/Frank/lib --with-sqlite3-dir=/Users/Frank/bin
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... no
checking for sqlite3_enable_load_extension()... no
checking for sqlite3_load_extension()... no
checking for sqlite3_open_v2()... yes
checking for sqlite3_prepare_v2()... yes
checking for sqlite3_int64 in sqlite3.h... yes
checking for sqlite3_uint64 in sqlite3.h... yes
creating Makefile
Which I think it has to do with the libsql-dev thats not working.
but then I get this
make
compiling backup.c
In file included from ./sqlite3_ruby.h:51,
from backup.c:3:
./backup.h:7: error: expected specifier-qualifier-list before ‘sqlite3_backup’
backup.c: In function ‘initialize’:
backup.c:63: error: ‘sqlite3_backup’ undeclared (first use in this function)
backup.c:63: error: (Each undeclared identifier is reported only once
backup.c:63: error: for each function it appears in.)
backup.c:63: error: ‘pBackup’ undeclared (first use in this function)
backup.c:77: error: ‘sqlite3BackupRuby’ has no member named ‘p’
backup.c: In function ‘step’:
backup.c:101: error: ‘sqlite3BackupRuby’ has no member named ‘p’
backup.c:102: error: ‘sqlite3BackupRuby’ has no member named ‘p’
backup.c: In function ‘finish’:
backup.c:115: error: ‘sqlite3BackupRuby’ has no member named ‘p’
backup.c:116: error: ‘sqlite3BackupRuby’ has no member named ‘p’
backup.c:117: error: ‘sqlite3BackupRuby’ has no member named ‘p’
backup.c: In function ‘remaining’:
backup.c:133: error: ‘sqlite3BackupRuby’ has no member named ‘p’
backup.c:134: error: ‘sqlite3BackupRuby’ has no member named ‘p’
backup.c: In function ‘pagecount’:
backup.c:149: error: ‘sqlite3BackupRuby’ has no member named ‘p’
backup.c:150: error: ‘sqlite3BackupRuby’ has no member named ‘p’
make: *** [backup.o] Error 1
Gem files will remain installed in /Users/Frank/gems/gems/sqlite3-1.3.6 for inspection.
Results logged to /Users/Frank/gems/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.6), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.
I started getting it randmoly today and I can't run my rails apps without it. What can I do?
Was having this issue recently. Had to open up the XCode tools and accept the terms of service. Then everything worked fine. (Make sure you have XCode installed first)
Himanshu's link fixed my problem.
https://github.com/luislavena/sqlite3-ruby/issues/20

Cannot install sqlite3 gem on Mac OS X 10.5.8 (Leopard)

Using
Mac OS X 10.5.8 (Leopard)
ruby 1.9.3p0
gem version 1.8.14
sqlite3 Version 3.7.9
I also have installed Xcode 3.1.4 (not sure if this is used for installation of gems).
I fetched the sqlite3 gem
gem fetch sqlite3
Then unpacked it
gem unpack sqlite3-1.3.5.gem
And cd'ed into the new directory
cd sqlite3-1.3.5
Executed
ruby setup.rb config
Then cd'ed to ext/sqlite3
and then executed make
This is returning the following error messages:
usernamemac:sqlite3 username$ make
compiling backup.c
compiling database.c
database.c: In function 'initialize':
database.c:47: error: 'SQLITE_OPEN_READWRITE' undeclared (first use in this function)
database.c:47: error: (Each undeclared identifier is reported only once
database.c:47: error: for each function it appears in.)
database.c:47: error: 'SQLITE_OPEN_CREATE' undeclared (first use in this function)
database.c:79: error: 'SQLITE_OPEN_READONLY' undeclared (first use in this function)
database.c:81: warning: implicit declaration of function 'sqlite3_open_v2'
database.c: In function 'set_sqlite3_func_result':
database.c:285: error: 'sqlite3_int64' undeclared (first use in this function)
database.c:285: error: syntax error before 'long'
make: *** [database.o] Error 1
In the README.rdoc file of the gem I read about "enabling the option SQLITE_ENABLE_COLUMN_METADATA (see www.sqlite.org/compile.html for details)" but did not understand what should be done.
Can anyone please help me solve this issue?
I have tried other approaches such as
Error with MySql while doing Bundle Install
and I can't install sqlite3 gem but these did not work for me.
Update: I have similar issues when trying
rails new app1 -d mysql
create vendor/plugins/.gitkeep
run bundle install
/Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/generators/app_base.rb:232: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:209: warning: Insecure world writable dir /usr/local in PATH, mode 040777
Fetching source index for http://rubygems.org/
Installing rake (0.9.2.2)
...
Installing jquery-rails (1.0.19)
Installing mysql2 (0.3.11) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/username/.rbenv/versions/1.9.3-p0/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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
... (list of switches)
Gem files will remain installed in /Users/username/a/app1/vendor/bundle/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/username/a/app1/vendor/bundle/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
An error occured while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.
I already have the gem mysql2 (0.3.11) installed.
Update 2: When executing
gem update
I am getting the following when the sqlite3-ruby gem is being updated:
Updating sqlite3-ruby
Building native extensions. This could take a while...
/Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:48: warning: Insecure world writable dir /usr/local in PATH, mode 040777
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/Users/username/.rbenv/versions/1.9.3-p0/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... no
checking for sqlite3_backup_init()... no
checking for sqlite3_column_database_name()... no
checking for sqlite3_enable_load_extension()... no
checking for sqlite3_load_extension()... no
creating Makefile
make
compiling backup.c
compiling database.c
database.c: In function 'initialize':
database.c:47: error: 'SQLITE_OPEN_READWRITE' undeclared (first use in this function)
database.c:47: error: (Each undeclared identifier is reported only once
database.c:47: error: for each function it appears in.)
database.c:47: error: 'SQLITE_OPEN_CREATE' undeclared (first use in this function)
database.c:79: error: 'SQLITE_OPEN_READONLY' undeclared (first use in this function)
database.c:81: warning: implicit declaration of function 'sqlite3_open_v2'
database.c: In function 'set_sqlite3_func_result':
database.c:285: error: 'sqlite3_int64' undeclared (first use in this function)
database.c:285: error: syntax error before 'long'
make: *** [database.o] Error 1
Gem files will remain installed in /Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.5 for inspection.
Results logged to /Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.5/ext/sqlite3/gem_make.out
Gems updated: activesupport, activemodel, rack, journey, sprockets, actionpack, railties, coffee-rails, jquery-rails, minitest, rubygems-update, sass-rails
Installing ri documentation for activesupport-3.2.0.rc2...
Thanks
If you are running Mac OS 10.5.X or below, you can't run sqlite3. You need at least Snow Leopard to be able to compile it.
Instead try changing your Gemfile to use sqlite3-ruby 1.2.5
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'

Resources