Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bundler: always use latest revision of git branch in Gemfile

I have a Gemfile with a private git repo in the following format:

gem 'magic_beans', :git => "[email protected]:magic_beans.git', :branch => 'super_beans'

When I bundle install, the Gemfile.lock locks it to a specific SHA revision.

Can I get bundler to always check and use the latest SHA commit and/or update the Gemfile.lock? Notice that when I push updates to the super_beans branch I am not modifying the gem version.

Ideally, every time I run bundle it would check upstream git repo for a newer SHA revision of the branch.

like image 955
pithyless Avatar asked Nov 30 '11 10:11

pithyless


People also ask

What is bundled with in Gemfile lock?

lock file contains all the information about the gems that are currently installed. This file is created after we run the bundle install command. A Gemfile. lock has a list of the exact versions of the gems required for the application.

Should I Gemfile lock version?

You should always include your Gemfile. lock if you are writing an application. The community seems to (largely) agree that you should include it in any Gems you create as well.

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.


2 Answers

This isn't how bundler works. The point is to allow seamless versioning of dependencies. (particularly so you know exactly what version of the code is deployed at any given time).

If want the latest version, you should just run.

bundle update magic_beans

This is exactly the same functionality as if you just say

gem "rails"

I'd suggest though, if you have a range of specific things you want to update then add a custom binary (say an executable file named bundle_update)

#!/usr/bin/env bash
bundle install
bundle update magic_beans

Then just do a ./bundle_update when you want to update these things.

like image 60
Matthew Rudy Avatar answered Oct 03 '22 00:10

Matthew Rudy


You can run bundle update to update all or specific gems to their latest available version, as stated in the docs.

Would that help?

like image 22
leonardoborges Avatar answered Oct 03 '22 01:10

leonardoborges