Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can bundler show me which gems in Gemfile have newer versions (eg. dry-run of bundle update)

Tags:

ruby

bundler

Is there a way to run bundle update in pretend mode, similar to the -p (pretend) flag for Rails generators or cap's -n (dry-run) flag?

I'm imagining something like:

$> bundle update -p
Fetching source index for http://rubygems.org/
The following gems have updated versions:
...
list of gems
...
like image 993
Jeff Poulton Avatar asked Jan 14 '11 23:01

Jeff Poulton


People also ask

How do you update a gem to a specific version?

The correct way to update the version of a gem to a specific version is to specify the version you want in your Gemfile, then run bundle install . As for why your command line was failing, there is no -version option.

What is the difference between Gemfile and Gemfile lock?

The Gemfile is where you specify which gems you want to use, and lets you specify which versions. The Gemfile. lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.

What is bundled with in Gemfile lock?

Ruby apps will now have the `BUNDLED WITH` declaration in their `Gemfile. lock` removed after detecting Bundler version. The version listed in the BUNDLED WITH key of the Gemfile. lock is used by Heroku to detect what version of Bundler to use.


3 Answers

Bundler 1.1 introduced a new 'outdated' feature, which is exactly what I was looking for. Pat Shaughnessy has a great write-up on the new features. In his words, bundle outdated:

displays the gems it would download and install, but without actually doing it. This gives me the freedom to inspect the list and update just the gems I would like to.

This should make it a snap to see what gems are due for an update without actually modifying your source and local gems. Thanks Bundler!

like image 200
Jeff Poulton Avatar answered Oct 12 '22 11:10

Jeff Poulton


$ bundle update $ git diff Gemfile.lock $ git checkout Gemfile.lock 
like image 26
yfeldblum Avatar answered Oct 12 '22 11:10

yfeldblum


I was looking specifically for how to only show the outdated gems that are in my gemfile. Looks like this does it: bundle outdated --only-explicit

That will 'Only list gems specified in your Gemfile, not their dependencies'

Source: https://bundler.io/man/bundle-outdated.1.html

Hopefully this is helpful for someone else.

like image 27
Chnikki Avatar answered Oct 12 '22 13:10

Chnikki