Cocoapods: Fails to install cocoapods on Ruby 2.4

Created on 13 Dec 2016  路  15Comments  路  Source: CocoaPods/CocoaPods

Reproduction

[~]$ rbenv install 2.4.0-rc1
Downloading ruby-2.4.0-rc1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0-rc1.tar.bz2
Installing ruby-2.4.0-rc1...
Installed ruby-2.4.0-rc1 to /Users/watson/.rbenv/versions/2.4.0-rc1

[~]$ rbenv shell 2.4.0-rc1
[~]$ ruby -v
ruby 2.4.0rc1 (2016-12-12 trunk 57064) [x86_64-darwin16]

$ gem install cocoapods
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: json-1.8.3.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Users/watson/.rbenv/versions/2.4.0-rc1/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
/Users/watson/.rbenv/versions/2.4.0-rc1/bin/ruby -r ./siteconf20161213-75110-lmkniy.rb extconf.rb
creating Makefile

current directory: /Users/watson/.rbenv/versions/2.4.0-rc1/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /Users/watson/.rbenv/versions/2.4.0-rc1/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
generator.c:861:25: error: use of undeclared identifier 'rb_cFixnum'
    } else if (klass == rb_cFixnum) {
                        ^
generator.c:863:25: error: use of undeclared identifier 'rb_cBignum'
    } else if (klass == rb_cBignum) {
                        ^
generator.c:975:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "01", &opts);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2139:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2325:8: note: expanded from macro 'rb_scan_args0'
                     rb_scan_args_verify(fmt, varc), vars)
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2197:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2163:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2158:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2154:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generator.c:975:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "01", &opts);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2139:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2325:8: note: expanded from macro 'rb_scan_args0'
                     rb_scan_args_verify(fmt, varc), vars)
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2197:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2163:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2159:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs+1, varc, vari+1))
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2154:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generator.c:975:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "01", &opts);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2139:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2325:8: note: expanded from macro 'rb_scan_args0'
                     rb_scan_args_verify(fmt, varc), vars)
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2197:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2164:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs+1, varc, vari+1))
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2158:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2154:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generator.c:975:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "01", &opts);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2139:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2325:8: note: expanded from macro 'rb_scan_args0'
                     rb_scan_args_verify(fmt, varc), vars)
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2197:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2163:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2158:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2154:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generator.c:975:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "01", &opts);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2139:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2325:8: note: expanded from macro 'rb_scan_args0'
                     rb_scan_args_verify(fmt, varc), vars)
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2197:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2163:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2158:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2154:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generator.c:975:5: warning: division by zero is undefined [-Wdivision-by-zero]
    rb_scan_args(argc, argv, "01", &opts);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2139:9: note: expanded from macro 'rb_scan_args'
        rb_scan_args0(argc,argvp,fmt,\
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2325:8: note: expanded from macro 'rb_scan_args0'
                     rb_scan_args_verify(fmt, varc), vars)
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2197:11: note: expanded from macro 'rb_scan_args_verify'
        verify = rb_scan_args_verify_count(fmt, varc); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2163:6: note: expanded from macro 'rb_scan_args_count_hash'
     rb_scan_args_count_block(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2158:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/watson/.rbenv/versions/2.4.0-rc1/include/ruby-2.4.0/ruby/ruby.h:2154:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 warnings and 2 errors generated.
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/watson/.rbenv/versions/2.4.0-rc1/lib/ruby/gems/2.4.0/gems/json-1.8.3 for inspection.
Results logged to /Users/watson/.rbenv/versions/2.4.0-rc1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/json-1.8.3/gem_make.out

Detail

CocoaPods has dependency in activesupport gem

  s.add_runtime_dependency 'activesupport', '>= 4.0.2', '< 5'

And it try to install json v1.8.3. However, it cannot compile it with Ruby 2.4.

Please update activesupport or use json 2.0.0 or higher by adding following dependency

  s.add_runtime_dependency 'json', '>= 2.0.0'

Most helpful comment

Luckily cocoapods v1.0.1 still works, by running gem install cocoapods -v 1.0.1;
I'm using NativeScript and it requires cocoapods to be installed without specifying a specific version;

All 15 comments

Ah this is going to be a fun one, activesupport >= 5 is broken on macOS System Ruby.

@segiddins do you know of any good ways to handle this?

Use bundler and remove the activesupport <5 restriction is the only thing that comes to mind, but I know that isn't helpful

This issue is related to https://github.com/flori/json/issues/308

Install Cocoapods-app,
Click the button [ Install the command-Line Tool ].

@Raizo7777 thinks.this is a good idea.

I may be wrong, but I'm pretty sure @Watson1978 is looking to use cocoapods with RubyMotion, so the Cocoapods app likely isn't a solution for him. Same goes for me.

Luckily cocoapods v1.0.1 still works, by running gem install cocoapods -v 1.0.1;
I'm using NativeScript and it requires cocoapods to be installed without specifying a specific version;

Hey @DanToml is there any update on this? I can also downgrade Ruby to an earlier version I suppose, but I need CP for Swift 3...

ATM we're stuck between a rock and a hard place, activerecord 5 doesn't support system ruby - and we have to support that.

As mentioned you can use the cocoapods Mac app ( by installing the app, and using the pod from inside that ) which will not have these problems, you can downgrade your Ruby, or you can try help the json gem get a 1.x release which continues to work with ruby 2.4.0

Same error. Hopefully I'm not breaking anything in the process but to fix I used:
Install RVM \curl -sSL https://get.rvm.io | bash -s stable
Install Ruby 2.3.3 rvm install ruby-2.3.3
Install cocoapods gem install cocoapods
And pod install is now working.

If you have errors from gpg installing RVM:
rm -rf ~/.gnupg/
curl -#LO https://rvm.io/mpapis.asc
gpg --import mpapis.asc
\curl -sSL https://get.rvm.io | bash -s stable

Cocoapods-app also allowed me to run pod install

I have had success doing the following steps:

  1. Uninstall ruby via homebrew.
  2. Uninstall cocoapods
  3. Reinstall cocoapods under /usr/local/bin sudo gem install -n /usr/local/bin cocoapods
  4. reinstall ruby 2.4 via homebrew.

I have ruby 2.4 and cocoapods on my mac, and am able to run pod install without issue.

I'm seeing this same issue with Ruby 2.4.0, and sudo gem install -n /usr/local/bin cocoapods doesn't work - it just generates the same error. No errors after downgrading to 2.3.3.

Seems like fastlane fix this here: https://github.com/fastlane/fastlane/issues/7673#issuecomment-269417767, updating json gem to 1.8.5 or higher, cocoapods is using json 1.8.3

json v1.8.5 was released (https://rubygems.org/gems/json/versions/1.8.5)
It can be built with Ruby 2.4.0 and this issue was solved by it.

Thank you all!!

The way it works for me..

  1. Install ruby using home-brew
    brew install rbenv ruby-build
    rbenv install 2.6.3
    rbenv global 2.6.3

    1. Install Cocoapods

      gem install cocoapods

      if system terminate the install. write "sudo" before "gem". I mean

      sudo gem install cocoapods

Was this page helpful?
0 / 5 - 0 ratings

Related issues

k06a picture k06a  路  3Comments

hmistry picture hmistry  路  3Comments

tlandsmancars picture tlandsmancars  路  3Comments

intelliot picture intelliot  路  3Comments

Mingmingmew picture Mingmingmew  路  3Comments