Bundler: You are trying to install in deployment mode after changing your Gemfile

62,080

Solution 1

The error message you're getting regarding Gemfile.lock may be because your Gemfile and Gemfile.lock don't agree with each other. It sounds like you've changed something in your Gemfile since you last ran bundle install (or update). When you bundle install, it updates your Gemfile.lock with any changes you've made to Gemfile.

Make sure you run bundle install locally, and check-in to source control your newly updated Gemfile.lock after that. Then try deploying.

Edit: As recognised in the comments, a conditional in the Gemfile resulted in a valid Gemfile.lock on one platform, invalid on another. Providing a :platform flag for these platform-dependent gems in the Gemfile should solve the asymmetry.

Solution 2

vi .bundle/config

change the BUNDLE_FROZEN option from '1' to '0'

do "bundle install"


OR

run "bundle config"

see if the "frozen" value is true set it to false

bundle config frozen false

Solution 3

Watch out for global Bundler config.

I had a global config on my dev environment in ~/.bundle/config that I did not have in my CI / Production environment that caused the Gemfile.lock that was generated in my dev environment to be different than the one in my CI / Production environment.

In my case I was setting github.https to true in my dev environment but had no such config in my CI / Production environment. This caused the two Gemfile.lock files to be different.

Solution 4

When you see the following...

$ bundle install
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

If this is a development machine, remove the Gemfile freeze
by running `bundle install --no-deployment`.

You have added to the Gemfile:
* source: rubygems repository https://rubygems.org/
* rails (~> 3.2)
. . .

... Then, the problem is most likely that you have outdated .gem files in your vendor/cache directory.

Perhaps, you previously ran $bundle install --deployment which put some "outdated" .gem files in the cache?

In any case, you can get past this error by running: bundle install --no-deployment

That's one of the many great things about Rails... the error messages often tell you exactly what to do to fix the problem.

Solution 5

My specific problem was related to what reported by @JoshPinter, i.e. dev-vs-deploy host discrepancies in the protocol used by bundler to retrieve gems from github.

To make a long story short, all I had to was modify the following Gemfile entry...

gem 'activeadmin', github: 'activeadmin'

...to this secure syntax (see reference):

gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin.git'

And my deployments are back to normal.

Share:
62,080
JellicleCat
Author by

JellicleCat

MS in computer science. Some PhD research in CNN's for computer vision tasks under my belt. I also worked in cooperation between the RASCAL robotics lab and the UC Davis Center for Mind and Brain, on a control system for beamforming hearing aids. I currently work as a software engineer and sysadmin. I am a two-time all-American barebow archer. I enjoy family, nature, microcontrollers, watching cartoons, and programming.

Updated on October 04, 2020

Comments

  • JellicleCat
    JellicleCat over 3 years

    I'm pretty new to bundler and capistrano, and I'm trying to use them together. When I try to deploy, I get the message:

    You are trying to install in deployment mode after changing your Gemfile. Run `bundle install' elsewhere and add the updated Gemfile.lock to version control.

    I don't know how to satisfy the system that's complaining, and I don't understand why the complaint is coming up because I read in the doc:

    If a Gemfile.lock does exist, and you have updated your Gemfile(5), bundler will use the dependencies in the Gemfile.lock for all gems that you did not update, but will re-resolve the dependencies of gems that you did update. You can find more information about this update process below under CONSERVATIVE UPDATING.

    I interpret that to mean that the Bundler can handle the fact that my Gemfile is not whatever it expected. Any help?

    Specs: Ruby 1.9.3, Rails 3.2.3, Capistrano 2.12.0, Bundler 1.1.4, Windows 7, deploying to a Posix machine.

    Edit: My Gemfile includes logic blocks like the following:

    unless RbConfig::CONFIG['host_os'] === 'mingw32'
      # gem 'a' ...
    end