capistrano and assets:precompile not working due to rake versioning issue - ruby-on-rails

I get the following error on a capistrano deploy:
If I run that commmand from the command line, I get the following:
You have already activated rake 0.9.2, but your Gemfile requires rake 10.0.3. Using bundle exec may solve this.
From my Gemfile
gem 'rake', '10.0.3'
When I look at Gemfile.lock, I see only three mentions of rake:
railties (3.1.10)
rake (>= 0.8.7)
rake (10.0.3)
rake (= 10.0.3)
This seems like fixing it at 10.0.3 should be fine.
Why am I getting this and how do I resolve this? What would happen if I ran gem uninstall rake? Would Capistrano still work after that?
thx in advance
edit 1
different rake versions:
root#curren:/data/sites/domain.com/apps/app-rails/current# rake -V
rake, version 0.9.2
root#curren:/data/sites/domain.com/apps/app-rails/current# bundle exec rake -V
rake, version 10.0.3

For Cap 3:
SSHKit.config.command_map[:rake] = "bundle exec rake"

If there is no reason not to update rake, you can run
bundle update rake
This will actually update your Gemfile.lock to use the newest version of rake
if you want to keep rake 0.9.2 uninstall the newest
gem uninstall rake
#result on my box
Select gem to uninstall:
1. rake-0.8.7
2. rake-10.0.1
3. rake-10.0.2
4. All versions
This Yehuda Katz blog post explains more.

Related

Running rake db:migrate gives "Could not find coffee-script-source-1.3.3 in any of the sources" error

I just made a fresh Rails app (Rails v3.2.8) and tried running rake db:migrate with one migration, but I always get this error:
Could not find coffee-script-source-1.3.3 in any of the sources
Run `bundle install` to install missing gems.
However, when I run bundle install, it indicates that coffee-script-source-1.3.3 is already installed:
Using rake (0.9.2.2)
Using i18n (0.6.1)
Using multi_json (1.3.6)
....
Using coffee-script-source (1.3.3)
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Any ideas? If it helps, I am also running ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.1.0], which I installed via brew install ruby
Edit: I am not using rvm
It's possible that the rake task is not being executed in the context of your current bundle (specified by your Gemfile). To ensure your task is running in the proper context, run bundle exec rake db:migrate instead.
Running executables via bundle exec is considered to be the safest route as it guarantees that only the gems at versions you expect (ie: what is declared in your Gemfile.lock) will be used.
Source: bundle-exec man page

Need to uninstall rake 0.9.2.2 and install rake 0.8.7

I built a new clean VM, install rvm, and installed ruby 1.9.2 and ran gem install rails --version '=3.0.7'. So far so good. When I did gem list rake, I saw that rake 0.9.2.2 was installed and I need rake 0.8.7. I read up on uninstalling rake. Then installed gem install rake -v='0.8.7'. This is what I did and observed:
gem list rake
rake (0.9.2.2, 0.8.7)
gem uninstall rake 0.9.2.2
You have requested to uninstall the gem rake-0.8.7
.......
Continue [Yn]
Successfully unistalled rake 0.8.7
INFO: gem "0.9.2.2" is not installed
gem list rake
rake (0.9.2.2)
Ok so it shows both versons of rake installed at first, I specify to delete 0.9.2.2 and it says its uninstalling 0.8.7 and that it completed uninstalling 0.8.7. (Not what I entered) At the end it shows 0.9.2.2 still installed in gem list rake. I have gone through this iteration multiple times, same result every time.
In the end, I need Ruby 1.9.2; rails 3.0.7 and rake 0.8.7. The first two I have fine. But how do I get rake back to 0.8.7? Or is what I see just some trash left over in some inventory of gems and does not reflect reality? or can you be sure what you really have?
Thanks in advance.
Try using the following command
rvm use #global && gem uninstall rake
I was having this same issue with the predefined constatnts 'Ruby' & 'LN_SUPPORTED'.
However; my 'gem list' only was showing rake 0.9.2.2. So after I was able to install 0.8.7, everything started working again.
sudo gem install rake -v=0.8.7
Can you do a: sudo gem uninstall Rake without specifying a version to get rid of rake completely before trying to reinstall both versions? Or possibly (I know it's frowned upon, but... ) remove the rake gem folder?
Also, maybe you could add rake (0.9.2.2, 0.8.7) to your gemfile and then do a bundle update
This works for me:
gem uninstall rake --version 0.9.2.2

How to overcome Bundle resolve conflict when running specs

I just added rspec but get a bundler conflict when I try and run the specs, this does not happen if I run rake tasks or start the server.
bundle exec spec
/<snip>/gems/bundler-1.0.21/lib/bundler/resolver.rb:280:in `resolve': You have requested: (Bundler::GemNotFound)
nokogiri >= 0
The bundle currently has nokogiri locked at 1.5.0.
Try running `bundle update nokogiri`
I've tried running bundle update nokogiri and removing Gemfile.lock and rerunning bundle install. I've even tried rvm gemset empty and starting afresh.
Gemfile: https://gist.github.com/1342979
Gemfile.lock: https://gist.github.com/1342981
JRuby: 1.6.2
Rails: 3.0.10
Bundler: 1.0.21
It seems running rspec instead of spec works...

Trouble removing rake 0.9

I am having some trouble removing the rake gem version 0.9. I managed to run gem uninstall rake and I believed this to have deleted it. However, going back to gem list it still showed that it still exists.
Running gem env:
GEM PATHS:
/home/sean/.rvm/gems/ruby-1.9.2-p180
/home/sean/.rvm/gems/ruby-1.9.2-p180#global
I went into the #global directory and manually deleted it there, yet still it remains somewhere. I can see it when I run gem list. The 0.9 rake gem is causing problems for my Rails 3.0.7 application.
I ran gem list -d rake:
rake (0.9.0, 0.8.7)
Installed at
(0.9.0): /home/sean/.rvm/gems/ruby-1.9.2-p180#global
(0.8.7): /home/sean/.rvm/gems/ruby-1.9.2-p180
I don't see anything in the gems directory for ruby-1.9.2-p180#global
You should run
rvm use #global && gem uninstall rake -v 0.9.0
rvm use # && gem uninstall rake -v 0.9.0
to correctly remove rake 0.9.0 from rvm
In terminal type in: gem uninstall rake, then select version 0.9.0 when prompted.
Then modify your Gemfile within your Rails application:
gem 'rake', '0.8.7'
Then in terminal run:
bundle install
These steps should fix the problems you are having. Upgrade to rake again when you upgrade to rails 3.1.
If you're using rvm you get rake 0.9 installed "for free" in the global gemset which makes it hard (impossible?) to uninstall properly. gem uninstall rake is successful but doesn't actually remove rake 0.9. I had to do it manually for both REE and 1.9.2.
I edited the rake executable script (find with which rake) and added a:
puts "Gem.bin_path: #{Gem.bin_path('rake', 'rake', version)}
...before the last line. This prints (on my system):
Gem.bin_path: ~/.rvm/gems/ree-1.8.7-2011.03#global/gems/rake-0.9.0/bin/rake
To remove 0.9 cd into ~/.rvm/gems/ree-1.8.7-2011.03 and manually delete all rake-0.9 files (gems, specifications are the ones that count I believe).
I ran into this same problem (needed rake 0.8.7 but got 0.9.0 "for free" with rvm). Initially gem list -d rake gave the following output:
rake (0.9.0, 0.8.7)
Installed at (0.9.0): ~/.rvm/gems/ruby-1.9.2-p136#global
(0.8.7): ~/.rvm/gems/ruby-1.9.2-p136#my_gemset
Switching to the global gemset with rvm use #global gave me this output:
rake (0.9.0)
Installed at: ~/.rvm/gems/ruby-1.9.2-p136#global
So I just did gem uninstall rake. Now, switching back to my gemset with rvm use #my_gemset the correct version of rake (0.8.7) is being used.
If you're using bundler, you should read this excellent article by Yehuda Katz. Following his instructions means you don't have to uninstall rake 0.9.0. Try following command:
bundle exec rake --version
Prepending bundle exec will make sure that only the correct version of the rake is loaded, regardless of others you have installed.
Did you try using the 'gem cleanup' script ?

You have already activated rake 0.9.0, but your Gemfile requires rake 0.8.7

I'm trying to run rails project,
I get
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
If I do: "bundle install"
but
I'm getting
You have already activated rake 0.9.0, but your Gemfile requires rake 0.8.7
while doing
rake db:migrate
First, check to make sure that rake is mentioned in your Gemfile. If it's not, add it, and specify the version "you already activated".
Then, you'll need to tell bundle to update the rake version it's using for your app:
bundle update rake
It'll update your Gemfile.lock for you.
Where you are currently using rake commands like
rake db:migrate
Use this instead:
bundle exec rake db:migrate
this will be the case until the latest version of rails and/or rake work well together.
I thank to Dobry Den, cheers dude. but little more I had to do.
here is solution (works for me).
I had added
gem 'rake','0.8.7'
on Gemfile, which was not there, but my new version of rails automatically install rake(0.9.0).
after I had delete rake0.9.0 by gem uninstall rake
and after doing bundle update rake , I can create and migrate database.
Rake 0.9.0 breaks rails.
See here: Rake 0.9.0 'undefined method 'task' '
Use bundle exec rake instead of rake to run rake at the correct version.
Specify the version that you want in your Gemfile.
gem 'rake', '0.9.0'
then
bundle update rake
you need to use bundle exec to run your rake task
bundle exec rake db:migrate
Oh look, it's the future. For me, it was complaining I had rake 10.x installed when it wanted 0.9.5. Not quite sure, not familiar enough with Ruby to really dig into what happened to the recent version numbers, but what I did was:
gem uninstall rake
gem install rake -v 0.9.5
to force the system to install the version of rake that the app wanted (for me it was Octopress).
I had this problem (with another gem that was not rake) and I was able to fix it by
gem uninstall <complaining gem>
gem install <complaining gem>
bundle install
bundle update
Note that the keyword 'sudo' was not used (ie. sudo bundle install) as that may place your gem into directories where your rails app might not be searching in.
Add this to your Gemfile
# Rake 0.9.0 break Rails.
gem "rake", "!= 0.9.0"
And then uninstall rake-0.9.0
If I understand what you're not asking, you need to open your Gemfile file and change the line...
gem 'rake', '0.8.7'
...to...
gem 'rake', '0.9.0'

Resources