I ran 'gem update' by accident can i revert it? - ruby-on-rails

I ran 'gem update' to try to fix a problem in a different app i was working on. Now my main app doesn't work properly because i have a bunch of too-new gems. Is there a way to undo the gem update? Or revert my gems to the versions mentioned in my team's Gemfile.lock file?
Update: It specifically complains about Rake when i try to run 'rake spec'
(Gem::LoadError: You have already activated rake 10.5.0, but your Gemfile requires rake 10.4.2. Prepending bundle exec to your command may solve this.)

If you currently have a more recent version of a gem than is specified in your Gemfile.lock, then it should suffice to rewrite the Gemfile with the versions mentioned in Gemfile.lock and run a bundle install.
I tested this locally (downgraded a version in both Gemfile.lock and Gemfile) and bundler installed the old version without problems.

Run 'gem uninstall rake' if you have multiple versions it will ask you which you wish to remove.
Then run 'gem install rake -v 10.4.2' to install the right version.
Worked for me and much less risky than bundle updating everything.

Related

Rollback gems according to version in Gemfile.lock

I need to revert back to an older set of gems in my dev environment. I've replaced my Gemfile.lock file with the old versions I need.
I thought I could just replace the Gemfile.lock and bundle install, but that doesn't seem to work. When I do that, then check the gem version numbers, I get the same versions I had before.
One of the gems I need to downgrade is the rake gem. The version I need is 11.1.2 but currently when I do gem list I get rake (12.0.0, 11.1.2, 10.4.2)
How can I revert rake and all the other gems back to their previous versions?
If you would like to clean out old gems no longer in your Gemfile.lock, you can run bundle clean.
However, even though the gems are still there, they are not being used if you run a task with bundle exec.
This is what I needed.. gem uninstall <gem name> and then if there are multiple gems you can pick which version you want to uninstall!

Your bundle is locked to rake (12.0.0), but that version could not be found in any of the sources listed in your Gemfile.

I get the following error message when starting the rails server:
Your bundle is locked to rake (12.0.0), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of rake (12.0.0) has removed it. You'll need to update your bundle to a different version of rake (12.0.0) that hasn't been removed in order to install.
I specified gem 'rake', '12.0.0' in the gemfile but that doesn't fix it. I tried bundle update rake, deleting the Gemfile.lock and generating it with bundle exec bundle install. I also prepended `bundle exec1 to al my commands which does nothing.
My Gemfile.lock already specifies rake version 12.0.0, and there are no other versions installed.
See my gemfile:
http://pastebin.com/L4tVFWz9
And rakefile:
http://pastebin.com/K7p2ajsE
I tried the solutions suggested in Already activated rake version different than what Gemfile requires prevents rake commands
Different methods to solve this issue,
Step1:
gem install rubygems-bundler
gem regenerate_binstubs
Step2:
Remove the vendor/bundle directory.
Run bundle install to rebuild it
Step3:
Try, gem update bundler
Here is a link where the issue got solved. Check this is very useful
Try:
gem install rubygems-bundler
gem regenerate_binstubs
Not really a fundamental solution, but if you really have to run some Rails commands urgently and needs a temporary fix, try bundle exec rails c rather than bin/rails c.
Enter command :-
bundle update rake

rake not working because "cannot find rdoc"

This is probably part of a larger problem because I've been troubleshooting one problem only to encounter a new one. I finally deleted the whole directory and pulled down a fresh copy, but I'm still having the same problem:
$ rake db:migrate
Could not find rdoc-4.2.0 in any of the sources
Run `bundle install` to install missing gems.
$
Running 'bundle install' does not fix the problem. When I look at the gemfile, it specifies rdoc 4.2.0, but gem list only has later versions. Attempting to 'gem install rdoc 4.2.0' results in:
ERROR: Could not find a valid gem '4.2.0' (>= 0) in any repository
Which I suppose means it's not available anymore. I suppose I could change the version in the Gemfile, but this is a shared repository and I don't want to bork it up for someone else.
What do I do now?
As it turns out, I was on a different version of Ruby (1.9.3) than I had been before. I changed to a later version and ran 'bundle update'. My rake commands work now.

Bundle Update stuck at "Fetching source index for http://rubygems.org/"

As of yesterday, I'm unable to update my bundle. It gets stuck at "Fetching source index for http://rubygems.org/". I know this usually takes a while, but I've waited for hours and tried several times over the last day. I have a 20 Mbit internet connection.
I'm using gem 1.8.5, Bundler version 1.0.15, rvm 0.1.46, ruby-1.9.2-p0 [ x86_64 ] and Rails 3.0.8 on a Macbook. Gemfile: https://gist.github.com/1028832
The reason I'm trying to run Bundle Update is because the bundle was set to rake 0.8.7 until recently (not sure why), but rake started demanding that I move up to 0.9.2. So I changed the Gemfile. Bundle Install tells me to:
bundle install
Fetching source index for http://rubygems.org/
You have requested:
rake >= 0.9.2
The bundle currently has rake locked at 0.8.7.
Try running `bundle update rake`
My .bundle/config contains:
---
BUNDLE_DISABLE_SHARED_GEMS: "1"
BUNDLE_WITHOUT: production
I'm not behind a proxy.
I even tried deleting Gemfile.lock, reinstalling the ruby version in rvm and deleting all gems:
rm Gemfile.lock
rvm uninstall 1.9.2
rvm install 1.9.2
for x in `gem list --no-versions`;do gem uninstall $x -aIx;done
gem install bundle
bundle install
Comment out all gems and set explicit versions for rails (e.g. 3.0.8) and rake (e.g. 0.9.2). Then just run rake, cucumber and the server to see which gems you really need and add them back one by one manually.
I had the same problem with jam at “Fetching source index for http://rubygems.org/”
In my case it was solved by using the rubygems modern index instead of the API endpoint:
bundle install --full-index
I checked the Gemfile.lock and added the specific version (e.g. ~> 1.3.0) to the gems that had none in the Gemfile. Found out to be faster, than uncommenting gem by gem.
By doing the accepted answer and uncommenting gem by gem, I found that the error was due to incompatible gem dependencies. Maybe the resolution algorithm was stuck in a loop.

undefined method `call' for :err:Symbol after bundle update

After pulling my application, I noticed I had to run bundle install (I'm using rails 3 and ruby 1.9 at Ubuntu 10.10).
Bundler indicated a gem conflict and told me to bundle update. After that, my application broke giving me the following error:
https://gist.github.com/979975
At config/environment.rb:5, I only have
TopTal::Application.initialize!
I reinstalled rvm, ruby, ran bundle install again but the error still appears here. Does anyone have any idea?
Be careful with "bundle update"! When you ran it, bundler ignored the previously installed gems in Gemfile.lock and updated many or all of your gems. I suggest you revert your Gemfile and Gemfile.lock back to before you did the update and try bundle install again. Note the gem with the conflict and then do "bundle update gem_name". This should update only the gem with the problem.

Resources