Bundle install: ERROR: Failed to build gem native extension. nio4r gem - ruby-on-rails

I'm currently working on a project using:
rvm 1.26.11
ruby 2.2.1p85
I tried to run bundle install but keep getting the following error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
and, following:
An error occurred while installing nio4r (1.0.0), and Bundler cannot continue.
Make sure that `gem install nio4r -v '1.0.0'` succeeds before bundling.
When I try running gem install nio4r -v '1.0.0':
Building native extensions. This could take a while...
ERROR: Error installing nio4r:
ERROR: Failed to build gem native extension.
When I try running bundle update:
Please make sure you have the correct access rights
and the repository exists.
Retrying git clone 'git#github.com:kshmir/requirejs-rails.git' ....*
Git error: command `git clone 'git#github.com:kshmir/requirejs-rails.git'.... has failed
When I try running bundle update nio4r:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension....
An error occurred while installing eventmachine (1.0.3), and Bundler cannot continue.
Make sure that `gem install eventmachine -v '1.0.3'` succeeds before bundling.
I tried that command too, to no result.
I also tried changing Ruby version:
rvm use 2.2.1 2.2.0 2.0.0 and running the commands above, but it doesn't change anything
Edit:
The output from running bundle install log:
Fetching gem metadata from rubygems....... Fetching version metadata from rubygems... Fetching dependency metadata from rubygems.. Using rake 10.2.2 Using i18n
0.7.0 Using multi_json 1.11.0 Using activesupport 3.2.17 Using builder 3.0.4 Using activemodel 3.2.17 Using erubis 2.7.0 Using journey 1.0.4 Using rack 1.4.5 Using rack-cache 1.2 Using rack-test 0.6.2 Using hike
1.2.3 Using tilt 1.4.1 Using sprockets 2.2.2 Using actionpack 3.2.17 Using mime-types 1.25.1 Using polyglot 0.3.4 Using treetop 1.4.15 Using mail 2.5.4 Using actionmailer 3.2.17 Using arbre 1.0.1 Using sass 3.2.19 Using thor 0.19.1 Using bourbon 3.1.8 Using bcrypt 3.1.7 Using bcrypt-ruby 3.1.5 Using orm_adapter 0.5.0 Using rack-ssl 1.3.4 Using json 1.8.1 Using rdoc 3.12.2 Using railties 3.2.17 Using atomic
1.1.15 Using thread_safe 0.2.0 Using warden 1.2.3 Using devise 3.2.3 Using formtastic 2.2.1 Using has_scope 0.6.0.rc Using responders 1.0.0 Using inherited_resources 1.4.1 Using jquery-rails 2.3.0 Using kaminari 0.15.1 Using arel 3.0.3 Using tzinfo 0.3.39 Using activerecord 3.2.17 Using polyamorous 0.5.0 Using meta_search 1.1.3 Using activeresource 3.2.17 Using bundler 1.8.4 Using rails 3.2.17 Using activeadmin 0.6.2 Using rgeo 0.3.20 Using rgeo-activerecord
0.5.0 Using activerecord-postgis-adapter 0.6.5 Using addressable 2.3.5 Using airbrake 3.1.16 Using descendants_tracker 0.0.3 Using ice_nine
0.11.0 Using axiom-types 0.0.5 Using coderay 1.1.0 Using better_errors 1.1.0 Using debug_inspector 0.0.2 Using binding_of_caller 0.7.2 Using bootstrap-datepicker-rails 1.1.1.8 Using bootstrap-sass 3.1.1.0 Using browser 0.8.0 Using columnize 0.3.6 Using debugger-linecache 1.2.0 Using byebug 2.7.0 Using cancan 1.6.10 Using highline 1.6.21 Using net-ssh 2.8.0 Using net-scp 1.1.2 Using net-sftp 2.1.2 Using net-ssh-gateway 1.2.0 Using capistrano 2.15.5 Using mini_portile 0.5.2 Using nokogiri 1.6.1 Using ffi 1.9.3 Using childprocess 0.5.1 Using rubyzip 1.1.0 Using websocket 1.0.7 Using selenium-webdriver 2.40.0 Using xpath 1.0.0 Using capybara 2.0.2 Using carrierwave 0.10.0 Using carrierwave_backgrounder 0.3.0 Using hitimes 1.2.2 Using timers 4.0.1 Using celluloid 0.16.0
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/home/adrian/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150424-28432-11y95op.rb extconf.rb checking for rb_thread_blocking_region()... no checking for sys/select.h... yes checking for poll.h... yes checking for sys/epoll.h... yes checking for sys/event.h... no checking for port.h... no checking for sys/resource.h... yes creating Makefile
make "DESTDIR=" clean
make "DESTDIR=" compiling selector.c In file included from nio4r.h:10:0,
from selector.c:6: /home/adrian/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h" [-Wcpp]
#warning use "ruby/io.h" instead of "rubyio.h" ^ In file included from selector.c:7:0: /home/adrian/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete [-Wcpp] #warning rubysig.h is obsolete ^ selector.c: In function ‘NIO_Selector_allocate’: selector.c:94:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
ev_init(&selector->timer, NIO_Selector_timeout_callback);
^ selector.c:94:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c:94:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c:99:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
ev_io_init(&selector->wakeup, NIO_Selector_wakeup_callback, selector->wakeup_reader, EV_READ);
^ selector.c:99:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c:99:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c: In function ‘NIO_Selector_synchronize’: selector.c:159:11: warning: variable ‘current_thread’ set but not used [-Wunused-but-set-variable]
VALUE current_thread, lock_holder, lock;
^ selector.c: In function ‘NIO_Selector_deregister_synchronized’: selector.c:241:11: warning: unused variable ‘monitor_args’ [-Wunused-variable]
VALUE monitor_args[3];
^ selector.c:240:21: warning: unused variable ‘interests’ [-Wunused-variable]
VALUE self, io, interests, selectables, monitor;
^ selector.c: In function ‘NIO_Selector_select’: selector.c:268:20: warning: unused variable ‘array’ [-Wunused-variable]
VALUE timeout, array;
^ selector.c: In function ‘NIO_Selector_select_synchronized’: selector.c:286:9: warning: unused variable ‘i’ [-Wunused-variable]
int i, ready;
^ selector.c: In function ‘NIO_Selector_run’: selector.c:326:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ev_tstamp started_at = ev_now(selector->ev_loop);
^ selector.c:341:9: error: ‘TRAP_BEG’ undeclared (first use in this function)
TRAP_BEG;
^ selector.c:341:9: note: each undeclared identifier is reported only once for each function it appears in selector.c:343:9: error: ‘TRAP_END’ undeclared (first use in this function)
TRAP_END;
^ selector.c:347:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
ev_timer_init(&selector->timer, NIO_Selector_timeout_callback, BUSYWAIT_INTERVAL, BUSYWAIT_INTERVAL);
^ selector.c:347:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c:347:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c:347:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] selector.c: In function ‘NIO_Selector_close’: selector.c:391:5: warning: passing argument 2 of ‘NIO_Selector_synchronize’ from incompatible pointer type [enabled by default]
return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
^ selector.c:157:14: note: expected ‘VALUE (*)(VALUE *)’ but argument is of type ‘VALUE (*)(VALUE)’ static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE
*args)
^ selector.c:391:5: warning: passing argument 3 of ‘NIO_Selector_synchronize’ makes pointer from integer without a cast [enabled by default]
return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
^ selector.c:157:14: note: expected ‘VALUE *’ but argument is of type ‘VALUE’ static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
^ selector.c: In function ‘NIO_Selector_closed’: selector.c:407:5: warning: passing argument 2 of ‘NIO_Selector_synchronize’ from incompatible pointer type [enabled by default]
return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
^ selector.c:157:14: note: expected ‘VALUE (*)(VALUE *)’ but argument is of type ‘VALUE (*)(VALUE)’ static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE
*args)
^ selector.c:407:5: warning: passing argument 3 of ‘NIO_Selector_synchronize’ makes pointer from integer without a cast [enabled by default]
return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
^ selector.c:157:14: note: expected ‘VALUE *’ but argument is of type ‘VALUE’ static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
^ selector.c: In function ‘NIO_Selector_wakeup’: selector.c:384:10: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(selector->wakeup_writer, "\0", 1);
^ make: *** [selector.o] Error 1
make failed, exit code 2
Gem files will remain installed in /home/adrian/.rvm/gems/ruby-2.2.1/gems/nio4r-1.0.0 for inspection. Results logged to /home/adrian/.rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/nio4r-1.0.0/gem_make.out An error occurred while installing nio4r (1.0.0), and Bundler cannot continue. Make sure that `gem install nio4r -v '1.0.0'` succeeds before bundling.

If you are working on Mac OSX above version 10.11.x, the following approach worked for me:
gem install nio4r -v '1.1.0' -- with-cflags="-std=c99"

I solved it with:
sudo apt-get install libmysqlclient-dev
sudo apt-get install libpq-dev
sudo apt-get install libsqlite3-dev
sudo apt-get install libev-dev
rvm use 2.0.0
Reboot pc
If I run rails -v shows me:
Rails 3.2.17
And now I can make Bundle install
I think the rails version was in conflict. I don't know why, maybe anyone can explain me.

bundle config build.nio4r --with-cflags="-std=c99"
bundle install
works for me

Update to version 1.0.4 if you're using Ruby 2.2.1

Works fine with macOS Sierra (10.12.2) after running the following command:
xcode-select --install
Before i had:
An error occurred while installing nio4r (1.2.1), and Bundler cannot continue.

Setting the bundle config didn't work for me...
If you've recently updated Xcode, make sure to actually run the application and accept the terms of service.
In my bundle error, I was getting You have to install development tools first.

This happened to me and it was because a new version of XCODE was installed and I hadn't accepted the new terms and conditions. Looking at the mkmf.log showed the following:
Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.

Related

Can't Install ffi -v '1.9.18' on macos Catalina

Can't install specific ffi version. If I run gem install ffi, everything works just fine but I need specific version 1.9.18 and it doesn't work.
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: /Users/chille/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/ffi-
1.9.18/ext/ffi_c
/Users/chille/.rbenv/versions/2.6.5/bin/ruby -I
/Users/chille/.rbenv/versions/2.6.5/lib/ruby/2.6.0 -r
./siteconf20200928-22154-72wopi.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: /Users/chille/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/ffi-
1.9.18/ext/ffi_c
make "DESTDIR=" clean
current directory: /Users/chille/.rbenv/versions/2.6.5/lib/ruby/gems/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
/Users/chille/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/ffi-1.9.18 for inspection.
Results logged to /Users/chille/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-
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' succeeds before bundling.
In Gemfile:
bootstrap-sass was resolved to 3.3.7, 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
To get past that error, install ffi using:
gem install ffi -v '1.9.18' -- --with-cflags="-Wno-error=implicit-function-declaration"
if you want bundle install ffi 1.9.8
bundle config --local build.ffi --with-cflags=-Wno-error=implicit-function-declaration
bundle install
For those who can, I think bumping ffi version should be preferred here. bundle update ffi took me from from 1.9.18 to 1.13.1 and built successfully for me.
#denis-osmerovic, unless you have another dependency holding ffi back, you should also be able to bump ffi. Checking my dependency chain, my ffi dependency is also coming from rb-inotify 0.9.10, same as yours. The listed requirement is for ffi (>= 0.5.0, < 2), so 1.13.1 should be acceptable.
Other background:
I previously had a working copy of ffi 1.19.18, and I don't remember needing to pass any special build flags. In order to reproduce this I uninstalled and tried to reinstall that version. I'm guessing other library or toolchain updates in the meantime broke this.
I am running ruby 2.6.3 on OS X 10.15.7 alongside Xcode 12.0.1
On an M1 Catalina 11.6, I was able to get past the error by first doing:
bundle update ffi
Then because I did not care about which version:
gem install ffi -- --with-cflags="-Wno-error=implicit-function-declaration"
If you need a version, other answers have that.
Due to the very nature of what the ffi gem does, it is tightly bound to the internals of the YARV engine. Therefore, you need to make sure you use a version of YARV that matches the version of the ffi gem.
In 2017, that would have been Ruby 2.4. Note that as of April 2020, Ruby 2.4 is no longer supported.

Error installing gem bson_ext version 1.5.1

I am trying to set up a ruby 2.3.0 project in my system . Upon running bundle install , I am getting the following error :-
Fetching bson_ext 1.5.1
Installing bson_ext 1.5.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/admin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bson_ext-1.5.1/ext/cbson
/Users/admin/.rbenv/versions/2.3.0/bin/ruby -I /Users/admin/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0 -r ./siteconf20201009-77301-z7iyto.rb
extconf.rb
checking for asprintf()... yes
checking for ruby/st.h... yes
checking for ruby/regex.h... yes
checking for ruby/encoding.h... yes
creating Makefile
current directory: /Users/admin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bson_ext-1.5.1/ext/cbson
make "DESTDIR=" clean
current directory: /Users/admin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bson_ext-1.5.1/ext/cbson
make "DESTDIR="
compiling encoding_helpers.c
compiling cbson.c
cbson.c:118:36: warning: passing 'char *' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Wpointer-sign]
result_t status = check_string(RSTRING_PTR(string), RSTRING_LEN(string),
^~~~~~~~~~~~~~~~~~~
/Users/admin/.rbenv/versions/2.3.0/include/ruby-2.3.0/ruby/ruby.h:994:5: note: expanded from macro 'RSTRING_PTR'
(!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./encoding_helpers.h:26:44: note: passing argument to parameter 'string' here
result_t check_string(const unsigned char* string, const int length,
^
cbson.c:602:18: error: implicit declaration of function 'bson_buffer_get_max_size' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (length > bson_buffer_get_max_size(buffer)) {
^
cbson.c:602:18: note: did you mean 'bson_buffer_set_max_size'?
./bson_buffer.h:34:6: note: 'bson_buffer_set_max_size' declared here
void bson_buffer_set_max_size(bson_buffer_t buffer, int max_size);
^
1 warning and 1 error generated.
make: *** [cbson.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/admin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bson_ext-1.5.1 for inspection.
Results logged to /Users/admin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-18/2.3.0-static/bson_ext-1.5.1/gem_make.out
An error occurred while installing bson_ext (1.5.1), and Bundler cannot continue.
Make sure that `gem install bson_ext -v '1.5.1'` succeeds before bundling.
In Gemfile:
bson_ext
Changing the bson_ext version does not work . I specifically need version 1.5.1 for the project.
Please help !!!

Bundle install error json gem

I've got the following problem with ruby on rails v 5.1.6 (Ruby version 2.5.0), the most of the time I try to run the command bundle install on a rails project downloaded from github, I get the following error.
Fetching gem metadata from http://rubygems.org/..........
Using rake 0.8.7z
Using abstract 1.0.0
Using activesupport 3.0.7
Using builder 2.1.2
Using i18n 0.5.0
Using activemodel 3.0.7
Using erubis 2.6.6
Using rack 1.2.8
Using rack-mount 0.6.14
Using rack-test 0.5.7
Using tzinfo 0.3.37
Using actionpack 3.0.7
Using mime-types 1.23
Using polyglot 0.3.3
Using treetop 1.4.14
Using mail 2.2.20
Using actionmailer 3.0.7
Using arel 2.0.10
Using activerecord 3.0.7
Using activeresource 3.0.7
Using addressable 2.3.4
Fetching json 1.8.0
Installing json 1.8.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/daniele/.rvm/gems/ruby-2.5.0/gems/json-1.8.0/ext/json/ext/generator
/home/daniele/.rvm/rubies/ruby-2.5.0/bin/ruby -r ./siteconf20180512-28287-pzwgum.rb extconf.rb
creating Makefile
current directory: /home/daniele/.rvm/gems/ruby-2.5.0/gems/json-1.8.0/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /home/daniele/.rvm/gems/ruby-2.5.0/gems/json-1.8.0/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:0:
../fbuffer/fbuffer.h: In function ‘fbuffer_to_s’:
../fbuffer/fbuffer.h:175:47: error: macro "rb_str_new" requires 2 arguments, but only 1 given
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
../fbuffer/fbuffer.h:175:20: warning: initialization makes integer from pointer without a cast
[-Wint-conversion]
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
generator.c: In function ‘generate_json’:
generator.c:840:25: error: ‘rb_cFixnum’ undeclared (first use in this function)
} else if (klass == rb_cFixnum) {
^
generator.c:840:25: note: each undeclared identifier is reported only once for each function it
appears in
generator.c:842:25: error: ‘rb_cBignum’ undeclared (first use in this function)
} else if (klass == rb_cBignum) {
^
generator.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
cc1: warning: unrecognized command line option ‘-Wno-tautological-compare’
Makefile:241: set di istruzioni per l'obiettivo "generator.o" non riuscito
make: *** [generator.o] Errore 1
make failed, exit code 2
Gem files will remain installed in /home/daniele/.rvm/gems/ruby-2.5.0/gems/json-1.8.0 for
inspection.
Results logged to
/home/daniele/.rvm/gems/ruby-2.5.0/extensions/x86_64-linux/2.5.0/json-1.8.0/gem_make.out
An error occurred while installing json (1.8.0), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.0'` succeeds before bundling.
In Gemfile:
airbrake was resolved to 3.1.12, which depends on
json
What Could the error be?
How can I fix it?
Thanks for helping.

Error installing json Ruby gem

I'm running gem install json -v '1.8.1' however I get this error..
gem install json -v '1.8.1'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: /Users/johnwilliamson/.rvm/gems/ruby-2.4.1/gems/json-1.8.1/ext/json/ext/generator
/Users/johnwilliamson/.rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20170412-72871-wada1h.rb extconf.rb
creating Makefile
current directory: /Users/johnwilliamson/.rvm/gems/ruby-2.4.1/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /Users/johnwilliamson/.rvm/gems/ruby-2.4.1/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:47: error: too few arguments provided to function-like macro invocation
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
/Users/johnwilliamson/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0/ruby/intern.h:795:9: note: macro 'rb_str_new' defined here
#define rb_str_new(str, len) RB_GNUC_EXTENSION_BLOCK( \
^
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:11: warning: incompatible pointer to integer conversion initializing 'VALUE' (aka 'unsigned long') with an expression of type 'VALUE (const char *, long)' (aka 'unsigned long (const char *, long)') [-Wint-conversion]
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^ ~~~~~~~~~~
generator.c:840:25: error: use of undeclared identifier 'rb_cFixnum'
} else if (klass == rb_cFixnum) {
^
generator.c:842:25: error: use of undeclared identifier 'rb_cBignum'
} else if (klass == rb_cBignum) {
^
1 warning and 3 errors generated.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/johnwilliamson/.rvm/gems/ruby-2.4.1/gems/json-1.8.1 for inspection.
Results logged to /Users/johnwilliamson/.rvm/gems/ruby-2.4.1/extensions/x86_64-darwin-16/2.4.0/json-1.8.1/gem_make.out
When I run just gem install json it installs fine taking me over version 2 however I'm trying to install this https://github.com/peatio/peatio and it wants that version specifically.
Any other ideas?
Finding and updating the gem that is pulling in the JSON gem should work. However, another thing that worked for me was to update the version of JSON being installed.
bundle update json
This worked because it updated JSON to version 1.8.6 which is compatible with newer Rubies.
This seems to be a common issue with the json 1.8.1 gem. You can use a different version of json if you are declaring it explicitly, but in some cases, json 1.8.1 is a cascading dependency. For instance, you may see something like
In Gemfile:
rails was resolved to 4.1.5, which depends on
actionmailer was resolved to 4.1.5, which depends on
actionpack was resolved to 4.1.5, which depends on
actionview was resolved to 4.1.5, which depends on
activesupport was resolved to 4.1.5, which depends on
json
In this case, you just need to change the top level gem (in this case rails) to a different version. 4.2.6 works.
The issue is arise due to you are not in proper directory. Please go to your rails directory folder first then run this command like this:
rails#rails:~/rails_project/btc$ gem install json -v '1.8.1'
Then its work fine.

PgSql and Sqlite3 are butting heads. I think I accidently installed 64 bit versions on a 32 bit machine and now I can't fix this

I was working on a super simple rails app, had a couple of errors and before I knew it things got out of control. I was having problems with the pg gem, so I went around trying to find a solution. I believe I may have installed something I shouldn't have. After I run
bundle install
I get this:
LMagnotti$ bundle install
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Resolving dependencies...
Using rake 11.1.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4
Using mime-types-data 3.2016.0221
Using arel 6.0.3
Your user account isn't allowed to install to the system Rubygems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to Rubygems using sudo.
Password:
Installing ansi 1.5.0
Using debug_inspector 0.0.2
Using sass 3.4.22
Using bundler 1.12.4
Using byebug 9.0.0
Installing coderay 1.1.1
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using thor 0.19.1
Using concurrent-ruby 1.0.2
Installing ffi 1.9.10 with native extensions
Installing formatador 0.2.5
Installing rb-fsevent 0.9.7
Installing ruby_dep 1.3.1
Installing lumberjack 1.0.10
Installing nenv 0.3.0
Installing shellany 0.0.1
Installing method_source 0.8.2
Installing slop 3.6.0
Using multi_json 1.12.0
Installing ruby-progressbar 1.8.1
Installing pg 0.18.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /private/var/folders/9k/wywr5gq52gsf8vxlbj5pgzb80000gn/T/bundler20160517-99984-1hhq594pg-0.18.4/gems/pg-0.18.4/ext
/usr/local/opt/ruby/bin/ruby -r ./siteconf20160517-99984-1fco5r9.rb extconf.rb --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Using config values from /usr/pgsql-9.1/bin/pg_config
sh: /usr/pgsql-9.1/bin/pg_config: No such file or directory
sh: /usr/pgsql-9.1/bin/pg_config: No such file or directory
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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
--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=/usr/local/Cellar/ruby/2.3.0/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/folders/9k/wywr5gq52gsf8vxlbj5pgzb80000gn/T/bundler20160517-99984-1hhq594pg-0.18.4/extensions/x86_64-darwin-15/2.3.0/pg-0.18.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/folders/9k/wywr5gq52gsf8vxlbj5pgzb80000gn/T/bundler20160517-99984-1hhq594pg-0.18.4/gems/pg-0.18.4 for inspection.
Results logged to /var/folders/9k/wywr5gq52gsf8vxlbj5pgzb80000gn/T/bundler20160517-99984-1hhq594pg-0.18.4/extensions/x86_64-darwin-15/2.3.0/pg-0.18.4/gem_make.out
Installing rails_serve_static_assets 0.0.5
Installing rails_stdout_logging 0.0.5
Using tilt 2.0.2
Using spring 1.7.1
Installing sqlite3 1.3.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /private/var/folders/9k/wywr5gq52gsf8vxlbj5pgzb80000gn/T/bundler20160517-99984-q4b85ssqlite3-1.3.7/gems/sqlite3-1.3.7/ext/sqlite3
/usr/local/opt/ruby/bin/ruby -r ./siteconf20160517-99984-s84g71.rb 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()... 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
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/folders/9k/wywr5gq52gsf8vxlbj5pgzb80000gn/T/bundler20160517-99984-q4b85ssqlite3-1.3.7/extensions/x86_64-darwin-15/2.3.0/sqlite3-1.3.7/mkmf.log
current directory: /private/var/folders/9k/wywr5gq52gsf8vxlbj5pgzb80000gn/T/bundler20160517-99984-q4b85ssqlite3-1.3.7/gems/sqlite3-1.3.7/ext/sqlite3
make "DESTDIR=" clean
current directory: /private/var/folders/9k/wywr5gq52gsf8vxlbj5pgzb80000gn/T/bundler20160517-99984-q4b85ssqlite3-1.3.7/gems/sqlite3-1.3.7/ext/sqlite3
make "DESTDIR="
compiling backup.c
compiling database.c
compiling exception.c
compiling sqlite3.c
compiling statement.c
statement.c:82:13: warning: unused variable 'db' [-Wunused-variable]
sqlite3 * db;
^
statement.c:260:11: warning: implicit declaration of function 'RBIGNUM' is invalid in C99 [-Wimplicit-function-declaration]
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^
./sqlite3_ruby.h:16:24: note: expanded from macro 'RBIGNUM_LEN'
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
^
statement.c:260:11: error: member reference type 'int' is not a pointer
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^~~~~~~~~~~~~~~~~~
./sqlite3_ruby.h:16:36: note: expanded from macro 'RBIGNUM_LEN'
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
~~~~~~~~~~ ^
statement.c:260:32: error: use of undeclared identifier 'SIZEOF_BDIGITS'
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^
2 warnings and 2 errors generated.
make: *** [statement.o] Error 1
make failed, exit code 2
Gem files will remain installed in /var/folders/9k/wywr5gq52gsf8vxlbj5pgzb80000gn/T/bundler20160517-99984-q4b85ssqlite3-1.3.7/gems/sqlite3-1.3.7 for inspection.
Results logged to /var/folders/9k/wywr5gq52gsf8vxlbj5pgzb80000gn/T/bundler20160517-99984-q4b85ssqlite3-1.3.7/extensions/x86_64-darwin-15/2.3.0/sqlite3-1.3.7/gem_make.out
Using rdoc 4.2.2
Using tzinfo 1.2.2
Using nokogiri 1.6.7.2
Using rack-test 0.6.3
Using mime-types 3.0
Using binding_of_caller 0.7.2
Using bootstrap-sass 3.2.0.2
Using coffee-script 2.4.1
Using uglifier 3.0.0
Using sprockets 3.6.0
Installing rb-inotify 0.9.7
Installing notiffany 0.0.8
Installing pry 0.10.3
Installing minitest-reporters 1.0.5
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.
Any ideas? Thanks!
Most of the times this error
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
happens because you haven't installed all you need to build Postgresql native extension. They are called 'native' because they are compiled in your machine and you need to fulfill all requirements to build them.
If you have installed all the basic developer packages, all you need to do is install the development package for Postgresql.
If you are using a Debian-like Linux (like Ubuntu), do:
sudo apt-get install libpq-dev
If your are with another Linux distribution, try to find the corrrect package. If you are using a Mac, read this.

Resources