mystic cola
mystic cola

Reputation: 1643

Can't get Cocoapods to work in a mixed Ruby Environment (OSX Sierra)

So I'm running OSX Sierra and I have a couple of Rails apps installed and Ruby 2.3.1 installed using rvm.

This seems to have created some sort of a conflict with Cocoapods which was installed using Homebrew (brew install cocoapods). Orginally I ran into the error that thread_safe wasn't installed... so I installed that (gem install thread_safe) THEN i ran into the problem that i18n wasn't installed... so I installed that... but I keep getting the error that it ISN'T installed.

It looks like cocoapods is trying to run another ruby version (2.6.5) from /usr/bin/ while it's simultaneously trying to run gems from 2.3.1.

I have NO IDEA how to fix this. Any help would be appreciated:

Traceback (most recent call last):
    19: from /usr/local/Cellar/cocoapods/1.8.4/libexec/bin/pod:23:in `<main>'
    18: from /usr/local/Cellar/cocoapods/1.8.4/libexec/bin/pod:23:in `load'
    17: from /Users/rainless/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/cocoapods-1.8.4/bin/pod:36:in `<top (required)>'
    16: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    15: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    14: from /Users/rainless/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/cocoapods-1.8.4/lib/cocoapods.rb:8:in `<top (required)>'
    13: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    12: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    11: from /Users/rainless/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.1/lib/active_support/core_ext/string/inflections.rb:1:in `<top (required)>'
    10: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     9: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     8: from /Users/rainless/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.1/lib/active_support/inflector/methods.rb:3:in `<top (required)>'
     7: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     6: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     5: from /Users/rainless/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.1/lib/active_support/inflections.rb:1:in `<top (required)>'
     4: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     3: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     2: from /Users/rainless/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.1/lib/active_support/inflector/inflections.rb:1:in `<top (required)>'
     1: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- thread_safe (LoadError)

Upvotes: 0

Views: 1242

Answers (1)

mystic cola
mystic cola

Reputation: 1643

Well THIS was a fun one. Something screwed up must've happened when I tried to run:

sudo gem install -n /usr/local/bin cocoapods

Probably should've just run: "brew install cocoapods" but it's been a LONG time since I've run Homebrew. I almost forgot the "brew" command existed.

Anyway it became confused about which version of ruby I was using so I fixed this by making a .ruby-gemset file:

.ruby-gemset

homebrew

...and a .ruby-version file:

.ruby-version

ruby-2.3.3

After that it was a simple matter of running "gem install bundler" and "bundle install" with

gem 'cocoapods' 

...in the Gemfile.

That was it! Now Cocoapods works just fine and it's using the version of Ruby that I want it to use.

Upvotes: 1

Related Questions