On Mac OS X 10.9.0 through 10.9.2, Apple shipped a Ruby and RubyGems installation that was missing specifications for the libraries that are included with Ruby by default, which leads to the user having to install a gem like the JSON gem even though the user already has that library installed.
(This is even more problematic if you want users to be able to install gems without having to have a properly configured compiler toolchain. I.e. where you do not want users to have to install gems with C extensions, such as the JSON gem.)
This was fixed starting from Mac OS X 10.9.3.
The following libraries are installed by default and should have their specifications installed:
$ ls -l /Library/Ruby/Gems/2.0.0/specifications/default
-rw-r--r-- 1 eloy staff 766 Oct 28 13:26 bigdecimal-1.2.0.gemspec
-rw-r--r-- 1 eloy staff 601 Oct 28 13:26 io-console-0.4.2.gemspec
-rw-r--r-- 1 eloy staff 537 Oct 28 13:26 json-1.7.7.gemspec
-rw-r--r-- 1 eloy staff 341 Oct 28 13:26 minitest-4.3.2.gemspec
-rw-r--r-- 1 eloy staff 4836 Oct 28 13:26 psych-2.0.0.gemspec
-rw-r--r-- 1 eloy staff 1481 Oct 28 13:26 rake-0.9.6.gemspec
-rw-r--r-- 1 eloy staff 2758 Oct 28 13:26 rdoc-4.0.0.gemspec
-rw-r--r-- 1 eloy staff 762 Oct 28 13:26 test-unit-2.0.0.0.gemspec
To fix, for instance, the JSON gem, perform the following steps:
$ sudo mkdir /Library/Ruby/Gems/2.0.0/specifications/default
$ sudo curl -o /Library/Ruby/Gems/2.0.0/specifications/default/json-1.7.7.gemspec \
https://raw.githubusercontent.com/flori/json/v1.7.7/json.gemspec
After which you should have the following:
$ ls -l /Library/Ruby/Gems/2.0.0/specifications/default
-rw-r--r-- 1 root wheel 4842 Nov 3 13:32 json-1.7.7.gemspec
tried your code and
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
also in mkmf.log I see below error message. would be good if anyone can guide how to correct it
package configuration for libffi is not found
"xcrun clang -o conftest -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib -L. -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/lib -arch x86_64 -lruby.2.6 "
In file included from conftest.c:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks')
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char *argv)
4: {
5: return 0;
6: }
/ end */