bundle:install "Cannot write a changed lockfile while frozen" -- cross platform deployment problem

5,343 views
Skip to first unread message

Dean Richardson

unread,
May 20, 2013, 2:16:46 PM5/20/13
to ruby-b...@googlegroups.com
Hi:

I've recently upgraded my rails 2.3 app to 3.0, 3.1, and now 3.2. I've used bundler throughout, but only began having capistrano attempt to bundle:install with my latest commit. I'[m developing on Windows but deploying to Ubuntu linux, and bundle:install is failing with the error "Cannot write a changed lockfile while frozen".

Here's the capistrano output near the error:

  * ←[32m2013-05-20 12:55:23 executing `deploy:finalize_update'←[0m
    triggering before callbacks for `deploy:finalize_update'
  * ←[32m2013-05-20 12:55:23 executing `deploy:assets:symlink'←[0m
  * ←[33mexecuting "rm -rf /home/dean/rails_projects/molex_app/releases/20130520
175523/public/assets && mkdir -p /home/dean/rails_projects/molex_app/releases/20
130520175523/public && mkdir -p /home/dean/rails_projects/molex_app/shared/asset
s && ln -s /home/dean/rails_projects/molex_app/shared/assets /home/dean/rails_pr
ojects/molex_app/releases/20130520175523/public/assets"←[0m
    servers: ["10.24.5.50"]
    [10.24.5.50] executing command
    ←[2;37mcommand finished in 41ms←[0m
  * ←[32m2013-05-20 12:55:23 executing `bundle:install'←[0m
  * ←[33mexecuting "cd /home/dean/rails_projects/molex_app/releases/201305201755
23 && bundle install --gemfile /home/dean/rails_projects/molex_app/releases/2013
0520175523/Gemfile --path /home/dean/rails_projects/molex_app/shared/bundle --de
ployment --quiet --without development test"←[0m
    servers: ["10.24.5.50"]
    [10.24.5.50] executing command
 ** [out :: 10.24.5.50] Cannot write a changed lockfile while frozen.
    ←[2;37mcommand finished in 19696ms←[0m

Here's my Gemfile:

source "http://rubygems.org"
gem "rails", "3.2.13"
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'mysql2', "0.3.11"
gem 'rake', "10.0.3"
gem 'bundler'
gem 'will_paginate', "3.0.4"
gem 'mini_magick', "3.2"
gem 'paperclip', "2.7.0"
gem "workflow", "0.8.0"
gem "thinking-sphinx", "2.0.10"
gem "riddle", "1.5.0"
gem "rufus-scheduler", "2.0.8"
gem "googlecharts", "1.6.0"
gem 'jquery-rails', '1.0.19'
gem 'rubyzip', '0.9.9'
gem 'capistrano'
group :test, :development do
  gem 'rspec', "2.13.0"
  gem 'rspec-rails', "2.13.1"
  gem 'factory_girl_rails', "1.4.0"
  gem 'term-ansicolor'
  gem 'turn'
end
group :test do
  # bundler requires these gems while running tests
  gem 'factory_girl', "2.3.0"
  gem 'shoulda', "2.11.3"
  gem 'treetop', '>=1.2.4'
  gem 'polyglot', '>=0.2.4'
  gem "rcov", '0.9.11'
  gem 'webrat', "0.7.3"
  gem 'database_cleaner', "0.5.0"
  gem "selenium-client", "1.2.18"
  gem "win32console", :platforms => [:mingw]
  gem 'autotest-standalone', :require => 'autotest'
  gem 'autotest-rails-pure'
end
group :assets do
  gem 'sass-rails', "3.2.3"
  gem 'coffee-rails', "3.2.1"
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  gem 'therubyracer', :platform => :ruby
  gem 'uglifier', "1.0.3"
end

And here's my deploy.rb:

require 'thinking_sphinx/deploy/capistrano'
require 'bundler/capistrano'
default_run_options[:pty] = true
set :application, "molex_app"
set :repository,  [redacted]
set :scm, "git"
set :scm_username, [redacted]
set :scm_passphrase, [redacted]
set :scm_command, "git"
set :rails_env, "production"
set :use_sudo, false
set :branch, "master"
set :deploy_to, "/home/dean/rails_projects/#{application}"
set :deploy_via, :remote_cache
set :user, "dean"
set :password, [redacted]
role :web, [redacted]                          # Your HTTP server, Apache/etc
role :app, [redacted]                          # This may be the same as your `Web` server
role :db,  [redacted], :primary => true # This is where Rails migrations will run
role :db,  [redacted]
# from Stack Overflow, specific for Rails 3.1 and the asset pipeline:
set :normalize_asset_timestamps, false
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
  task :before_update_code, :roles => [:app] do
  thinking_sphinx.stop
  end
  task :after_update_code, :roles => [:app] do
  symlink_sphinx_indexes
  thinking_sphinx.configure
  thinking_sphinx.start
  end
  task :symlink_sphinx_indexes, :roles => [:app] do
  run "ln -nfs #{shared_path}/db/sphinx/production #{release_path}/db/sphinx/production"
  end
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end
 after "deploy:setup", "thinking_sphinx:shared_sphinx_folder"
From what I can tell, capistrano's doing just what it's supposed to, but bundle:install is failing on the production server. Googling this error message led me to several blog posts / forum questions that hint at issues when bundler is used to deploy across two different platforms (e.g., windows and unix.) That's my situation, so I'm guessing that's the problem here.

Can anyone help me understand what the error message is getting at and what I need to fix?

Thanks very much,

Dean Richardson

André Arko

unread,
May 21, 2013, 2:05:40 AM5/21/13
to ruby-b...@googlegroups.com
You need to run `bundle install`, then `git add Gemfile.lock`, and then commit and push. Only after you have committed the lock for the code you are trying to deploy will Bundler run in deployment mode.

--
You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler...@googlegroups.com.
To post to this group, send email to ruby-b...@googlegroups.com.
Visit this group at http://groups.google.com/group/ruby-bundler?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dean Richardson

unread,
May 21, 2013, 10:42:25 AM5/21/13
to ruby-b...@googlegroups.com
Andre:

Thanks for your reply. This sounds like a promising fix. Here's what happens when I try it, though:

bundle install yields a list of all the various gems in my gemfile, where each line starts with "using" and none of them start with "installing".
git add Gemfile.lock yields no output
git status at this point yields "on branch master, nothing to commit, working directory clean"
git commit -am "commit message" also yields "on branch master, nothing to commit, working directory clean"
git push yields "Everything up-to-date" after some warnings about push.default changing from matching to simple in git 2.0.
cap deploy then produces the same output in my original post, including the "Cannot write a changed lockfile while frozen" message.

Any ideas what I might be missing?

--Dean

André Arko

unread,
May 21, 2013, 11:31:08 PM5/21/13
to ruby-b...@googlegroups.com
Oh! Sorry, I missed a very important part of your message: "developing on Windows but deploying to Ubuntu". You can't use --deployment mode to do that.

Deployment mode exists to make sure that the gems you run in production are the same as the gems that you were running in development, and that is why the error you are seeing exists. The error is being raised in your case in particular because it is not possible to install exactly the same gems on both Windows and Linux, given your particular Gemfile.

To be able to deploy, you'll need to stop using the --deployment option. That may require overriding the default bundle install cap task, if that's what you're using.

Dean Richardson

unread,
May 21, 2013, 11:37:54 PM5/21/13
to ruby-b...@googlegroups.com
Hi Andre:

Sounds like we're really getting somewhere. :) I am using the default cap task for bundle install... My deploy.rb is in the original post, I think.

Can you please point me to a more appropriate capistrano task to handle this particular case? Or suggest how I might approach building a custom one?

Thanks!

--Dean
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler...@googlegroups.com.

To post to this group, send email to ruby-b...@googlegroups.com.
Visit this group at http://groups.google.com/group/ruby-bundler?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to a topic in the Google Groups "ruby-bundler" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ruby-bundler/Hu-2W39CU_g/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to ruby-bundler...@googlegroups.com.

André Arko

unread,
May 22, 2013, 12:05:02 AM5/22/13
to ruby-b...@googlegroups.com
There is no pre-built cap task that will do what you want, but there are a lot of docs around customizing the cap task in the cap task help. Run `cap -e bundle:install` to read them. Or just open the file `lib/bundler/capistrano.rb` in the Bundler source tree. :)

You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
Reply all
Reply to author
Forward
0 new messages