How to downgrande a gem in the gemfile? - ruby-on-rails

I have this in my Gemfile.lock
sequel (5.15.0)
I want to downgrade the gem version to the 4.39.0 so I go in my Gemfile and add a version next to the gem declaration:
gem 'sequel', '4.39.0'
and run bundle exec bundle install
But it gives me:
You have requested:
sequel = 4.39.0
The bundle currently has sequel locked at 5.15.0.
Try running `bundle update sequel`
If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
Run `bundle install` to install missing gems
.
So I try to run bundle exec bundle update sequel but it returns me the same message.
How can I downgrade the gem?

You need to just call
bundle update sequel
without the bundle exec in front.
The issue you experienced is caused by bundle exec evaluating your current Gemfile for executing the latter command first. Here, it finds the difference between the specified gems in the Gemfile and your current Gemfile.lock and bails out.
In general, no bundle calls need to ever be prefixed with a bundle exec.

First try to update the dependent gems. It could be that there are some broken dependencies to other gems if you are downgrading.
Best practice:
bundle update sequel dependent_gemnames...
If you do not find out the dependent gems you can also try to update all your gems. But attention! This can cause unwanted side effects.
bundle update
And the last and ugliest option is to remove your Gemfile.lock and run
bundle install
This will rebuild your full Gem Stack and should be able to create a working Gemfile.lock

Related

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

Rails could not find gem

when tried to start server rails s i have got
Could not find minitest-5.9.0 in any of the sources
Run `bundle install` to install missing gems.
i did gem install minitest -v 5.9.0
Successfully installed minitest-5.9.0
1 gem installed
also gem list
minitest (5.9.0, 4.7.5)
but when i try rails s again i received the same error.
How could i fix it?
bundle install
If you have tried that, try
bundle update
This will update your gems and your gemfile.lock
Best to specify the version you want in your Gemfile, at present you have 2 versions which will be causing the conflicts.
Something like gem 'minitest ', '~> 5.90' would do the trick. Once you have done this do bundle update this will ensure you update Gemfile to use the correct version of specified gem

I ran 'gem update' by accident can i revert it?

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.

Can't install ffi gem, Rails fail

While creating creating an integration test via rails generate integration_test foo it declined with
Could not find ffi-1.0.9 in any of the sources
Run `bundle install` to install missing gems.
I ran bundle install to install missing gems, but with no success. Still the same error. I have gem 'ffi' in my Gemfile.
I switched the gemfile line to gem 'ffi', :git => 'git://github.com/ffi/ffi.git' and bundle installed again. It did all sort of stuff and wrote "Your bundle is complete" at the end.
However when I run the rails generate... command again I get:
git://github.com/ffi/ffi.git (at master) is not checked out. Please run 'bundle install'
What the hell is going on with this ffi?
I ran into the same problem and solved it by removing the Gemfile.lock and re-run bundle install.
Perhaps try 'bundle exec rails generate...'
bundle install was failing because it could ffi failed with NoMethodError for spec.
Removing Gemfile.lock, empty the gemset and doing bundle install worked.

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.

Resources