I got the server with the configuration above.
This is the important part of my deploy.rb recipe:
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
require 'bundler/capistrano'
set :rvm_ruby_string, 'ruby-1.9.2-p290'
set :rvm_type, :system
set :bundle_flags, "--deployment"
set :default_environment, {
'PATH' => ENV['PATH'],
'RAILS_ENV' => ENV['RAILS_ENV']
}
set :stages, %w(staging production)
require 'capistrano/ext/multistage'
Running cap staging deploy
as is, leads to an error:
* executing "cd /mnt/data-store/project/releases/shared &&
bundle install --gemfile /mnt/data-store/project/releases/shared/Gemfile
--path /mnt/data-store/project/shared/bundle --deployment --without development test"
** [out :: localhost] The --deployment flag requires a Gemfile.lock.
Please make sure you have checked your Gemfile.lock into version control
before deploying.
... rolling back ...
failed: "env PATH=... RAILS_ENV=staging rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.2-p290' -c 'cd /mnt/data-store/project/releases/shared && bundle install --gemfile /mnt/data-store/project/releases/shared/Gemfile --path /mnt/data-store/project/shared/bundle --deployment --without development test'" on localhost
Gemfile and Gemfile.lock are in the source control. I ran bundle install
locally first to generate the .lock file. But the bundler/capistrano points to /mnt/data-store/project/releases/shared/Gemfile so I just copied manually both files there. I'm sure I'm doing it wrong here. I guess it should be copied automatically.
Executed deploy again (1) and it didn't fail on the bundle install, it even had
Your bundle is complete! It was installed into /mnt/data-store/project/shared/bundle
in the output.
BUT, one of my cap tasks executes a rake. The result of this is:
*Could not find bcrypt-ruby-3.0.1 in any of the sources
*Try running bundle install
.
Proceeding with my adventure, I discovered that once you have .bundle/config with
BUNDLE_PATH: /mnt/data-store/project/shared/bundle
It works.
I had this directory, probably created by bundler, under /mnt/data-store/releases/shared/
, so I copied manually to the rails root.
Now, rake/rails c work.
bundle show twitter
shows .../shared/bundle/ruby/1.9.1/gems/twitter-1.7.1
.
BUT, redeploying brings me back to (1), because the .bundle dir isn't there.
Concrete questions:
- Do I need to create/copy .bundle/config manually?
- Do I need to copy Gemfile/Gemfile.lock manually to the shared dir? What happens if I add gems? Should I hold two copies, or manually/programmatically sync them?
- WHAT AM I DOING WRONG?
Thanks!