Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating Gemfile.lock without installing gems

Is there a way to force an update of the Gemfile.lock without installing the gems that have changed?

like image 462
Automatico Avatar asked Oct 13 '14 08:10

Automatico


People also ask

How do I update my Gemfile lock?

To automatically update the Gemfile. lock with your current version of Bundler, run bundle update --bundler . In general, it's a good idea to use the latest version of Bundler. That's why my Ruby on Mac script is meant to be run often to keep your system up to date with the latest versions of Bundler and Rubygems.

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.

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.


3 Answers

Run bundle lock --update.

I found an answer in a blog post by Chris Blunt: “Rails on Docker: Quickly Create or Update Your Gemfile.lock”:

Today, I discovered a way to save the hours wasted downloading gems: bundler’s lock command.

This gem of a command resolves your app’s dependencies and writes out the appropriate Gemfile.lock – without installing any of the gems themselves.

According to the changelog, this command was added in Bundler 1.10.0.pre, released about eight months after this question was asked.

like image 135
alexwlchan Avatar answered Oct 19 '22 16:10

alexwlchan


Instead of

bundle install

do the following:

bundle lock

This will just update the Gemfile.lock, but not attempt to install the files locally.

If you want to prepare a Gemfile.lock for a remote or deployment platform you must add it using

bundle lock --add-platform ...

Latest docs at https://bundler.io/v1.16/man/bundle-lock.1.html

like image 42
Christopher Oezbek Avatar answered Oct 19 '22 15:10

Christopher Oezbek


Force your specific requirement using:

bundle inject rmagick "=1.7.1"
like image 3
Arnaud Meuret Avatar answered Oct 19 '22 14:10

Arnaud Meuret