Could not find json-1.8.1 in any of the sources - ruby-on-rails

I'm doing a project using react-rails but when I run
bundle install
I get
Could not find json-1.8.1 in any of the sources
Specifically, this is the entire error
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/montana/.rvm/gems/ruby-2.3.0/gems/json-1.8.1/ext/json/ext/generator
/Users/montana/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160629-5602-i1di2t.rb extconf.rb
creating Makefile
current directory: /Users/montana/.rvm/gems/ruby-2.3.0/gems/json-1.8.1/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /Users/montana/.rvm/gems/ruby-2.3.0/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/montana/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/intern.h:797:9: note: macro 'rb_str_new' defined here
#define rb_str_new(str, len) __extension__ ( \
^
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));
^ ~~~~~~~~~~
1 warning and 1 error generated.
make: *** [generator.o] Error 1
There's been various posts about this on stackoverflow, and have tried most "solutions' but none seem to work for me, I also ran
gem list | grep json
It says I have the json gem via
json (1.8.3)
multi_json (1.10.1)
I've tried to stop spring, updating the gems, & bundler. I've also ran
rbenv rehash
To no avail, still getting this error, any input would be highly appreciated.

I had a problem last time on Ubuntu, i tried to install this library and it worked as well.
sudo apt-get install libgmp3-dev
You can refer document at: Failed to build gem json native extension

You may want to lower down your ruby version or bump json version up. See: https://github.com/flori/json/issues/229
Had a quick look at json 1.8.1 gemspec and no mention of ruby 2.3.0 support as of today.

Related

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 !!!

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.

How do I build "gem install json"?

I’m using Rails 4.2.7. I’m trying to build this tutorial — https://github.com/webguyian/bookstore, but getting a strange error, “An error occurred while installing json (1.8.0), and Bundler cannot continue.” So I tried “gem install json -v '1.8.0'”
localhost:bookstore-master davea$ gem install json -v '1.8.0'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: /Users/davea/.rvm/gems/ruby-2.3.0/gems/json-1.8.0/ext/json/ext/generator
/Users/davea/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20161007-50119-1huurrz.rb extconf.rb
creating Makefile
current directory: /Users/davea/.rvm/gems/ruby-2.3.0/gems/json-1.8.0/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /Users/davea/.rvm/gems/ruby-2.3.0/gems/json-1.8.0/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/davea/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/intern.h:797:9: note: macro 'rb_str_new' defined here
#define rb_str_new(str, len) __extension__ ( \
^
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));
^ ~~~~~~~~~~
1 warning and 1 error generated.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/davea/.rvm/gems/ruby-2.3.0/gems/json-1.8.0 for inspection.
Results logged to /Users/davea/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-14/2.3.0/json-1.8.0/gem_make.out
I don’t know what this means or how to correct it. Any ideas?
The version of the json gem you are using is not compatible with Ruby >= 2.2. Please use at least version 1.8.2 of the json gem with Ruby 2.3.
See the Changelog for details about changes in functionality and compatibility.
That said, most of the time you don't even need an external gem to be able to work with JSON data in Ruby. The JSON module shipped with Ruby's standard library is fully functional and compatible with Rails already.

Can't install Puma gem on OSX 10.11.3

I just reformat my MacBook and I try to clone of my Rails project. When I do bundle install, Puma gem failed.
When I run gem install puma -v '2.13.4', I get this error:
Fetching: puma-2.13.4.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing puma:
ERROR: Failed to build gem native extension.
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20160211-95547-1pdaoaq.rb extconf.rb
checking for BIO_read() in -lcrypto... yes
checking for SSL_CTX_new() in -lssl... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling http11_parser.c
compiling io_buffer.c
io_buffer.c:119:10: warning: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]
return rb_str_new(b->top, b->cur - b->top);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:796:20: note: expanded from macro 'rb_str_new'
rb_str_new_static((str), (len)) : \
^~~~~
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:727:37: note: passing argument to parameter here
VALUE rb_str_new_static(const char *, long);
^
io_buffer.c:119:10: warning: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]
return rb_str_new(b->top, b->cur - b->top);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:797:13: note: expanded from macro 'rb_str_new'
rb_str_new((str), (len)); \
^~~~~
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:706:29: note: passing argument to parameter here
VALUE rb_str_new(const char*, long);
^
2 warnings generated.
compiling mini_ssl.c
In file included from mini_ssl.c:3:
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
^
mini_ssl.c:4:10: fatal error: 'openssl/bio.h' file not found
#include <openssl/bio.h>
^
1 warning and 1 error generated.
make: *** [mini_ssl.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/zulhilmi/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/puma-2.13.4 for inspection.
What should I do?
About my project and my environment:
Ruby: 2.2.0 (I'm using RVM)
Rails: 4.2.0
OSX: 10.11.3
Instead of force linking openssl(which is NOT recommended according to this Github Opened issue) as proposed by Zulhilmi Zainudin,
I recommend the following solution based on issue 783 of Puma source code(reference below).
I'm using El Capitan (10.11) with openssl installed via Homebrew:
$ gem install puma -v 2.13.4 -- --with-opt-dir=/usr/local/opt/openssl
Reference: https://github.com/puma/puma/issues/783
But if you want to make it work for all your Gemfiles you can still:
$ bundle config build.puma --with-opt-dir=/usr/local/opt/openssl
and confirm:
$ grep PUMA ~/.bundle/config
the output should be:
BUNDLE_BUILD__PUMA: "--with-opt-dir=/usr/local/opt/openssl"
Reference: https://github.com/puma/puma/issues/718
This solution works for me:
brew install openssl
brew link --force openssl

(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

Resources