Bundler: always use latest revision of git branch in Gemfile

bundler git
gem install from github command line
how to use a gemfile
how to open gemfile
install gem from private github repo
gemfile example
gemfile local gem
bundle config

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

gem 'magic_beans', :git => "git@git.example.com: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.

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.

Git, Setting them up is as easy as adding a gem to your Gemfile. Using the very latest version of a gem (or even a fork) is just as easy as using an official release. Specify that a git repository should use a particular ref, branch, or tag This ensures that a developer is always working against the correct branches, and prevents  Bundler adds the ability to use gems directly from git repositories. Setting them up is as easy as adding a gem to your Gemfile. Using the very latest version of a gem (or even a fork) is just as easy as using an official release.

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

Would that help?

How to install gems from git repositories, Installing a gem using git is as easy as adding a gem to your Gemfile. at the root of a git repository, you must specify a version that bundler should use when If the branch specified in the Gemfile and the current branch in the local git This ensures that a developer is always working against the correct branches, and  If the branch specified in the Gemfile and the current branch in the local git repository do not match, Bundler will abort. This ensures that a developer is always working against the correct branches, and prevents accidental locking to a different branch. Finally, Bundler also ensures that the current revision in the Gemfile.lock exists in the local git repository. By doing this, Bundler forces you to fetch the latest changes in the remotes.

After searching through the documents I finally found the magic way to do this:

bundle update magic_beans --source magic_beans

That is to update the magic_beans gem only, but not to touch other locked gems. The doc about this is: http://bundler.io/man/bundle-update.1.html

gemfile, Gemfile - A format for describing gem dependencies for Ruby programs If your application requires a specific Ruby version or engine, specify your requirements --without test , bundler will remember that you excluded the test group in the last installation. git "https://github.com/rails/rails.git", :branch => "5-0-stable" do. Bundler adds the ability to use gems directly from git repositories. Setting them up is as easy as adding a gem to your Gemfile. Using the very latest version of a gem (or even a fork) is just as easy as using an official release.

delete .gemlock is what worked for me :/

Version v1.2, You can now specify the version of Ruby in the Gemfile like the following: ruby '​1.9.3'. That line declares that this application has a dependency on the Ruby VM that If the branch specified in the Gemfile and the current branch in the local git This ensures that a developer is always working against the correct branches,​  Contribute to bundler/bundler development by creating an account on GitHub. # so the Gemfile.lock always picks up the new revision. {git_proxy.branch} but

bundle config, You can use bundle config to give Bundler the flags to pass to the gem installer This ensures that a developer is always working against the correct branches, and that the current revision in the Gemfile.lock exists in the local git repository. If I delete the "cache" directory, and bundle update my_gem it continues to checkout the wrong Git revision (expected, since it did not change in Gemfile.lock).. If I change the :branch with a :ref I get the correct revision, but I need to change it everytime.

Updating gems from git + branch · Issue #2165 · rubygems/bundler , So I use the :git feature of Bundler to checkout the gem's source code fr "​bundle update my_gem" does not grab the latest revision from the repo. # Gemfile gem 'my_gem', git: 'git@my:private-repo.git', branch: 'master' Introduce Bundler.original_system and Bundler.original_exec to shell out or exec to external programs using the original environment before bundler was loaded Add feature parity to bundle info GEM with respect to the old deprecated command bundle show GEM #7026

Gemfile Mining: A Dive into Bundler's Gemfile, If you're like me, I learned how to use the Gemfile and Bundler from various Rails (and other) tutorials. Always a good place to start, this is the stuff you probably already know. That line will pull in the latest version of the gem. gem "my-git-​gem", git: "https://github.com/me/my-git-gem.git", branch:  12 Bundler: always use latest revision of git branch in Gemfile Nov 30 '11. 7 Different .gitconfig for a given subdirectory? Dec 13 '11. 7 Different .gitconfig for a

Comments
  • If I change :git to use a :path instead, bundle install happily uses the newest SHA each time. I'll just keep using bundle update, but I don't think this is necessarily the ideal solution. After all, in my Gemfile I'm not scoping to a :revision but a :branch. Thanks for the input!
  • I know this is very old, but setting a :path always updates because it loads from a directory, not from a git repository or remote gem. :path is great for developing two projects together locally, but breaks down once you start collaborating.
  • I guess if app and gem repos both belongs to you, and the gem undergoes lots of small changes, it is painful to also do a commit on the main app to point to the latest commit all the time.
  • The first magic_beans is not necessary. You can just do bundle update --source magic_beans.