Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to update gems on production server

Can not update gems on production server.

I've tried bundle install --deployment and bundle install --without development test

But keep getting:

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 

EDIT

I don't know if this is correct, but needed a quick fix. I ran bundle install --no-deployment then bundle update then ran bundle install --deployment again

like image 394
pcasa Avatar asked Jul 22 '11 04:07

pcasa


People also ask

What is Gemfile lock file?

The Gemfile. lock allows you to specify the versions of the dependencies that your application needs in the Gemfile , while remembering all of the exact versions of third-party code that your application used when it last worked correctly. By specifying looser dependencies in your Gemfile (such as nokogiri ~> 1.4.

How is Gemfile lock generated?

Gemfile. lock is automatically generated when you run bundle install or bundle update . It should never be edited manually.


2 Answers

The instructions are probably a bit confusing. It's saying that you've modified your Gemfile on your development machine and just pushed those changes rather than running bundle install BEFORE committing the changes.

By running bundle install you will update your Gemfile.lock file. This should be pushed to your server as it's more important than Gemfile. Consider the Gemfile the plans for the Gemfile.lock file.

Always remember to:

  1. Run bundle install if you change your Gemfile, even just to make sure. If it's too slow, pass --local through which forces it to only use local gems to resolve its dependencies.
  2. Commit both the Gemfile and Gemfile.lock file to your repository
  3. Deploy both the Gemfile and Gemfile.lock to your production servers to ensure that they're running the exact same dependencies as your development environment.

Running bundle update by itself can be construed as dangerous that will update all the dependencies of your application. It's mainly dangerous if you don't have solid version numbers specified in the Gemfile. I wrote about it here.

like image 63
Ryan Bigg Avatar answered Sep 19 '22 20:09

Ryan Bigg


FWIW I had this problem and fixed it by removing some conditional statements from my Gemfile (conditionals on OS) and rerunning bundle.

like image 42
TomL Avatar answered Sep 17 '22 20:09

TomL