Prevent bundler from upgrading gems - ruby

I'm working on a project and we've just updated bundler to version 1.7.0. There was a few days of trouble in getting all the gemfiles/gemfile.locks in a correct state, but I'm still having trouble with one issue in particular.
If there are differences in Gemfile.lock, I check it out, and then bundle so that I will have the gems in the Gemfile. However bundle seems to always auto-upgrade my gems. For example:
Installing multi_json 1.10.1 (was 1.9.2)
The rest of my team is using 1.9.2 - there's a dependency in another part of the application or...who knows. I should be using 1.9.2, but bundler consistently 'auto-upgrades' everytime i run bundle. Is there a way to prevent this behavior? I'm using RVM 1.25.23

Bundler 1.7.0 has some bugs which can result in unexpected gem updates. Please try upgrading to the latest version (1.7.2 at the time that I write this).
See:
https://github.com/bundler/bundler/issues/3136
https://github.com/bundler/bundler/issues/3142
https://github.com/bundler/bundler/issues/3149

Try:
bundle install --frozen
This should prevent bundler to update the Gemfile.lock.

Related

Bundler version for Ruby 2.3.8?

I currently have 2 ruby versions, 2.5.5 and 2.3.8, I am managing them with rbenv, and for gems, I use bundler to manage my specific gem versions. I have an issue when I want to switch to a project that uses 2.3.8 or a version that has to do with Ruby version 2.3.
My question is how do I get bundler to run the command to bundle install interact with my 2.3 projects.
My current version of bundler is 2.0.2.
I have already tried installing a lower version of bundler of which the bundler website claims to interact with ruby version 2.3.
I thought that if I specified the command to run bundle _version_ install it would work, but it still gave me the response that it needed ruby version 2.5 for bundler to work.
Lots of help appreciated.
In some situations, isolation can help. I would like to recommend rvm (https://github.com/rvm/rvm) for managing ruby versions. This tool is very similar to rbenv but in comparison, it allows you to create gemsets which are kind of containers of gems for special purposes. For instance:
rvm install 2.5.5 --disable-binary
rvm use 2.5.5#name-of-gemset --create
gem install bundler
bundle install # inside your project folder with Gemfile
I think that you will not have problems with versions again.

rubygems automatically updating on install

I am currently managing an installation of ruby 1.9.3 in red hat 5.
I have found that, during a specific gem install, ruby is trying to download and install the latest version of a particular required gem.
I have attempted to prevent the updating of gems using the --conservative flag, however, this does not seem to work.
The gem in question requires a specific version of launchy which, in turn, requires a specific version of addressable.
The versions of these gems that are already installed meet the requirements of the gem I am attempting to install. However, the gem command attempts to download and install the latest version of addressable.
This is a problem, because the latest addressable requires public_suffix, which only installs in ruby 2.x and greater.
The gem that I am trying to install is a custom gem, and thus I have modified the gemspec, and found that removing the launchy requirement fixes the issue. However, launchy is a required gem, so the requirement needs to stay in the dependency list.
Has anyone had any experience with dealing with this particular version of ruby and gem and found issues with dependencies?
I have tried going in and modifying gemspec for launchy and addressable in the installed gems dirs, but have found that the issue is with the gem install command attempting to update/install the latest gems despite giving it flags telling it otherwise.
ruby 1.9.3
gem 1.8.23
After some additional research prompted by the above responses, it was determined that an outdated version of Hoe was causing the generated gem to try and install the latest dependencies. After moving away from Hoe to manage dependencies and versions, my issue has been solved.
Some of the dependency management classes seem to behave quite differently, so that's probably the first place to look.
Use the -v flag to specify the exact version to install:
gem install your-custom-gem -v 1.1

Installing webistrano on ubuntu 13.10

I'm trying to install webistrano with latest ruby packages on ubuntu 13.10.
After inital configuration, each time when I'm trying to "bundle" things I'm getting following error:
confiq#home:~$ RAILS_ENV=production rake db:migraterake aborted!
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (~> 1.0.10) ruby
Current Bundler version:
bundler (1.4.0.pre.1)
Of course, I tried to install older bundler
confiq#home:~/$ gem list bundler
*** LOCAL GEMS ***
bundler (1.4.0.pre.1, 1.3.5, 1.0.10)
But dosen't matter which version of bundler I'm installing it always fails on same error message.
I'm in middle of dependency hell and this is just small portion of it...
The error is happening because the project specification requires bundler ~> 1.0.10. This means every version of bundler 1.0.x is allowed, but not bundler 1.3 or 1.4.
Even if you install an older version of bundler, by default the most recent one is used when you call bundle from the command line.
To force the use of an older version, you need to pass it in the following way
$ bundler _1.0.10_ ...
One additional node. Webistrano is a very old and unmaintained project. The last commit is older than 3 years ago.
I discourage you to use the project. It's likely you will encounter several other incompatibilities and the time you will waste trying to find a solution may not be worth.

Capybara-1.1.1 conflicts with capybara (~> 0.4.0)

I updates my gems, now I get this error:
Unable to activate capybara-mechanize-0.2.7, because capybara-1.1.1 conflicts with capybara (~> 0.4.0) (Gem::LoadError)
I've googled and searched SO, but I'm a bit of a n00b and not really sure what I need to do next.
Thanks for your time,
Mike
You can try to delete conflicting gem by invoking gem uninstall capybara. You will be the prompted which version to delete.
To remove all old gems in one swipe just use gem cleanup.
After cleaning old version which, hopefully, you don't need you should be ok. Otherwise, consider using bundler (http://gembundler.com/) to manage gems in your projects and RVM, where you can have completely separate gemsets.
My general workflow is as follows:
In Rails/Sinatra etc applications I put vendor/cache in my .gitignore and run bundle pack which installs gems into that directory. That way I can keep installed gems local per application.
In my daily workflow I use RVM to switch ruby versions and install gems into gemsets which I can port across RVM rubies. http://beginrescuened.com. A popular and more lightweight alternative to RVM is https://github.com/sstephenson/rbenv.
So bundler manages my gem dependencies in a sane manner and RVM lets me manage gems at a granular level. I went through the dependency hell of plain old rubygems a while back, never again.
You've either got two versions of Capybara installed (both 1.1.1 and some other version). You can go a gem list --local (or if you're using Bundler do a bundle show) and uninstall one of them.
Or possibly you've specified that you want versions ~> 0.4.0, and the version number 1.1.1 is out of that range. That is, the specified version range ~> 0.4.0 will only work with 0.4.0 .. 0.4.x, and not 0.5.x or higher.

Bundler throws uninitialized constant Gem::SilentUI (NameError) error after upgrading to Rubygems 1.5.0

I ran gem update --system to update to Rubygems 1.5.0 and after every time I run any bundle commands I get:
rvm/gems/ruby-1.8.7-p249/gems/bundler-1.0.9/lib/bundler/ui.rb:56: uninitialized constant Gem::SilentUI (NameError)
Has anyone else had this issue?
Update to bundler 1.0.10 or above (gem update bundler). The issue is fixed in later versions.
If you're a bit vague on what bundler actually is and don't want to learn then the very short answer to the question is:
gem install bundler
This was posted on the issue tracker, by my count, 6 times now.
Here's the one that I've been linking everybody to: https://github.com/carlhuda/bundler/issues/issue/995
Re: "just Update to bundler 1.0.10." — Note that you can't necessarily get the new version simply by doing
sudo gem update
You'll need to fully uninstall your current bundler, ignore the warnings about the dependencies it breaks, and then re-install it. That fixed my Bundler 1.0.7 and got my system working again.
It looks like RubyGems 1.5.0, which just came out today, is incompatible with Bundler 1.0.9.
You'll probably want to downgrade back to RubyGems 1.4 until an update is released for Bundler (which will likely be very, very soon).
Update: Bundler 1.0.10 is out now.
You can also downgrade Rubygems, however this is less than ideal, but for legacy systems if you need a specific bundler version you will have to do this.
For example on the app I am working on at the moment we are using:
Ruby 1.8.6-p383
RubyGems 1.3.6
Bundler 0.9.26
Note that if you're using rvm, you may not be able to upgrade bundler yourself. You may need to upgrade rvm in order to update bundler, since rvm integrates bundler pretty tightly. I got this error, tried to upgrade bundler, couldn't, and upgrading rvm fixed my problem.

Resources