Error on require 'motion-cocoapods' with RubyMotion - ruby

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!

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.

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.

Related

Adding a customized version of bundler as a dependency in a Gemfile

How can I make a typical gem setup (as generated by bundle gem) run a customize version of bundler?
I've added:
#group :development do
gem "bundler", github: 'pjump/bundler'
#end
to my Gemfile (with or without the the hash symbols), and bundle install works, but bundle exec keeps telling me that the bundler repo is not yet checked out. The only way I can make it work for now is by installing the customized version with gem istall and not specifying a bundler dependency in the package at all.
Bundler isn't able to bootstrap itself from a Gemfile, so adding a customized version to your Gemfile will not do what you want. Installing it with gem install is the correct solution (or running rake install from the forked Bundler repo directory, which builds and installs the gem in one step).

How do I install a Ruby gem from GitHub and have it work in IRB?

Seems like every Ruby tutorial I find centers around Rails.
Anyway, I simply want to install a gem from a GitHub repo and have that gem work in irb.
I want to install the exifr gem. When I do a gem install exifr it doesn't get the newest version.
So I created a Gemfile and put:
gem 'exifr', :git => 'git://github.com/remvee/exifr.git'
Then bundle install. Installs OK but now gem list doesn't find the gem. So I can't require it in irb.
Any help for NON Rails applications?
Thanks
You need to kick off the bundler setup if you want to use the gems from a gemfile:
require 'bundler/setup'
require 'exifr'
or:
irb -rbundler/setup
> require 'exifr'
This is equivalent to running bundle exec irb, except it doesn't depend on a specific invocation to work, and instead presumes that a Gemfile is available and the gems were installed with Bundler.
Try...
bundle exec gem list
And..
bundle exec irb -rexifr
And see if that works. That should help gem/irb find the installed gem.

Rake at wrong version despite fresh uninstall/install procedures

I am trying to install RedMine on a server.
During the procedures as explained here i am supposed to run
rake generate_secret_token
However, i am getting this error:
(in /home/var/redmine)
rake aborted!
uninitialized constant Rake::DSL
/home/var/redmine/Rakefile:7
(See full trace by running task with --trace)
After some research i discovered that rake 0.8.7 is supposedly having problems with this (that, at least, is how i understood it) and that i am supposed to use rake 0.9.2.2
I tried adding
gem 'rake', '0.9.2.2'
to my Gemfile.
I checked
rake --version
And get
rake, version 0.8.7
I ran
gem uninstall rake
Which succeeded, according to the output.
Then i ran
gem install rake -v=0.9.2.2
And the output was
Successfully installed rake-0.9.2.2
1 gem installed
Installing ri documentation for rake-0.9.2.2...
Installing RDoc documentation for rake-0.9.2.2...
However, when then calling
rake --version
I still get
rake, version 0.8.7
I also experimented with adding
gem 'rake', '0.8.7'
to my Gemfile for redmine. However, then i get this response when running rake
You have requested:
rake = 0.8.7
The bundle currently has rake locked at 0.9.2.2.
Try running `bundle update rake`
What am i doing wrong here?
I was able to fix this strange issue by following these steps:
gem uninstall rake
Then
bundle update rake
This gave me the response that rake is already up-to-date, but still, i list it here - just in case.
Then
gem install rake -v=0.8.7
Furthermore in my Gemfile i had this configuration
source 'http://rubygems.org'
gem 'rails', '3.2.6'
gem 'rake', '0.8.7'
(In that order)
After doing all this i was able to run
rake generate_secret_token
successfully.
When using several versions of a same gem, you can specify which version to use using _version_ argument, eg. rake _0.9.2.2_ --version
(see gem help install)
To use Gemfile's version, you can prefix your command with bundle exec, eg. bundle exec rake --version (read "Getting started" from http://gembundler.com/)
Basically the different incompatible versions of rake are creating problem. This solved it for me:
/var/lib/gems/1.8/bin/rake generate_secret_token

Problems with bundled gems and datamapper: conflict with muti_json version?

I have a site running with nginx/unicorn/sinatra (bundler/rvm).
After my last bundle update, I am getting an error:
in `raise_if_conflicts': Unable to activate dm-serializer-1.2.1, because multi_json-1.3.5 conflicts with multi_json (~> 1.0.3)
My Gemfile is:
source "http://rubygems.org"
gem 'unicorn'
gem 'sinatra'
gem 'datamapper'
gem 'dm-mysql-adapter'
gem 'haml'
gem 'sass'
gem 'omniauth-twitter'
Gemfile.lock does not have any reference to multi_json 1.0.3
Any ideas?
Solution was:
check Gemfile.lock to see which gem(s) bring in later version (in this case - omniauth-twitter)
Find a version of 'offender' that does not require too high version
Rollback later versions, lock to a proper version in Gemfile
In this particular case, Gemfile that works needed lines:
gem 'omniauth-twitter', '0.0.9'
gem 'multi_json', '~> 1.0.3'
One of the gems in your bundle has an older version of multi_json as a dependency it looks like. See if bundle viz tells you. You'll need to install the ruby-graphviz gem and graphviz itself if you don't have them installed already, though.
Another way to see what's up is to add multi_json to your gemfile at the version you're trying to upgrade to, then do a bundle install and see what errors come out.
This is how to fix this problem:
rvm uninstall multi_json
It will tell you that you have many versions installed, show you a list of them, and ask you which one exactly you want to uninstall.
Try the first one, if it tells you that it is used by some other gem, try the second one, and so on. Keep deleting all the unused versions until only one remains.
This is how I do it, but there may be some clearner solution. If anyone knows it, thanks for sharing it with us.

Missing gem when running rake

I'm using rbenv with Ruby 1.9.2-p290, Rails 3.1, and the database is MySQL.
When I try
rake db:create
I get the following error:
Could not find multi_json-1.0.3 in any of the sources
I've also tried bundle exec rake db:create.
My GemFile looks like this:
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'mysql2'
gem 'json'
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
gem 'jquery-rails'
Quite old, but in case anyone else comes across this and is looking for the real answer: upgrade your bundler gem.
For me didn't work neither smathy and kalleth answers.
Always getting:
Could not find multi_json-1.3.0 in any of the sources
What it worked for me was deleting Gemfile.lock and running again bundle install
It installed a new version of multi_json:
Installing multi_json (1.3.2)
I ran into this problem too with a Rails 3.1 application + rails engines .
bundle exec rake -T reported the error you're reporting.
What solved it for me was running the following command to tell bundler to install the gems to the local 'vendor/bundle' path within the application with the following command:
bundle install --path=vendor/bundle
After I did that, bundle exec rake -T worked correctly.
I had the same problem, and used Jorge's answer to get to my solution:
bundle update multi_json
This just updates multi_json, and not all the other gems, which would potentially happen when you delete the Gemfile.lock and run "bundle install".
Always run your commands through bundle exec. That way you ensuer that you load the correct environment which is expected by your app. Use it like:
bundle exec rake db:migrate
Also make sure you have actually run bundle install to install all required gems and their dependencies.

Resources