AwDogsGo2Heaven
AwDogsGo2Heaven

Reputation: 972

Error on require 'motion-cocoapods' with RubyMotion

I just got Ruby motion, and I wanted to try out Cocoapods. I installed it just as it asks on the website:

http://www.rubymotion.com/developer-center/articles/cocoapods/

I add

require 'motion-cocoapods' to my simple 'Hello' project. And I get this error when trying to rake it:

rake aborted! Unable to activate cocoapods-0.16.1, because rake-10.0.3 conflicts with rake (~> 0.9.4)

I guess this has something to do with my version of rake, but I have no idea what I need to do to fix this problem. Please help!

Upvotes: 1

Views: 1027

Answers (2)

Dylan Markow
Dylan Markow

Reputation: 124419

This is caused by having a version of rake newer than 0.9.x installed. When you just run rake, it loads up the newest version (10.0.3 in your case). Then, when the cocoapod gem tries to load, it tries to activate rake 0.9.x and fails (the ~> 0.9.4 means that it will accept any version starting with 0.9.).

One solution would be to completely remove the rake gem and install the 0.9.4 version explicitly:

gem uninstall rake
gem install rake --version '0.9.6'

However, this could become an issue if you have any other projects that require a newer version of rake. A better solution would be to use Bundler:

gem install bundler

Create a Gemfile in your project folder containing:

source :rubygems
gem 'rake'
gem 'motion-cocoapods'

Add the following to Rakefile, immediately under the require 'motion/project' line:

require 'bundler'
Bundler.require

Then run bundle install from the console. This will lock this specific project on rake 0.9.6. The only catch is that you'll probably need to prefix all of your rake commands with bundle exec.

Upvotes: 3

AwDogsGo2Heaven
AwDogsGo2Heaven

Reputation: 972

I was able to solve this issue by following the steps on this japanese blog:

http://blog.amacou.net/post/37702092871/rubymotion-cocoapods-rake

First uninstall:

gem uninstall motion-cocoapods gem uninstall cocoapods

download cocoapods :

git clone git://github.com/CocoaPods/CocoaPods.git

find the gemspec file

and change this:

s.add_runtime_dependency 'rake', '~> 0.9.4'

to this:

s.add_runtime_dependency 'rake', '> 0.9.4'

then install it as a gem

rake gem:install

then reinstall motion-cocoapods:

gem install motion-cocoapods

My feeling is this is a hack though, and I'm worried it could cause problems else where. If anyone has a better answer, please post it.

Upvotes: 0

Related Questions