Rake at wrong version despite fresh uninstall/install procedures - ruby

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

Related

Redmine installation issue

I'm trying to install Redmine 2.3 from SVN (http://redmine.rubyforge.org/svn/branches/2.3-stable/)
I am using this tutorial (http://www.redmine.org/projects/redmine/wiki/HowToInstallRedmineOnUbuntuServer) as Ruby is not really my piece of cake....
I'm getting an error when running a command: rake generate_session_store
Could not find gem 'rails (= 2.3.14)' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.
I installed rails, but I still get the same error... searched for answers but this is really driving me crazy now.
:/usr/share/redmine# rails -v
Rails 2.3.14
Could anyone with more experience shed some light on it?
Run to install all dependent gems bundle install
run
bundle exec rake generate_session_store
this will call rake in scope of current installed gems.
In Redmine 2.x you have to use
rake generate_secret_token
Instead of the old (which is for Redmine 1.4.x)
rake generate_session_store
Source: http://www.redmine.org/projects/redmine/wiki/RedmineInstall

You have already activated rake 0.9.6, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this

Before continue reading, I must says that I already read and tried similar questions and answers on google & stackoverflow.
My problem is that:
bundle install or update does nothing
gem uninstall rake refuses because rake is a default gem
I cannot use bundle exec for all my commands
Any other idea ?!
At the root of project, do:
gem list rake
You will see probably more than one version. If so, then remove the version you don't need (i.e. 0.9.6) by command:
gem uninstall rake
it will ask which version to remove. Or try doing
bundle update rake
I solved this by just doing
gem install rake
This solved my issue
bundle update rake
You might have old version of rake installed. In that case, use:
gem list rake
If the output shows only one version as:
*** LOCAL GEMS ***
rake (0.9.6)
Then simply installed the newer version
gem install rake
I know it has been 2 months but just wanted to share how I solved this issue. Have you tried deleting gemfile.lock? It solves my problem:
rm Gemfile.lock
bundle
Since it's your base installed gem that's out of date, simply use
gem update rake

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!
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.

Bundle exec rake db:migrate does not work (and neither does rake db:migrate), Ubuntu

I am running a Rails 3 app on Ubuntu (EC2), I have rake locked at version 0.8.7 and when I do rake db:migrate I get the usual:
You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.8.7. Using bundle exec may solve this.
However when I do bundle exec rake db:migrate, I get the same response..
??
There are a couple of things that you can try:
Upgrade Ruby to 1.9.3 which will provide Rake 0.9.2.2
Add this to your Gemfile gem 'rake' , '>= 0.9.2' and run bundle update again.
Worst case, delete your Gemfile.lock and regenerate it again using bundle install

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