简体   繁体   English

Gemfile.lock,Bundler和Capistrano部署

[英]Gemfile.lock, Bundler and Deploying with Capistrano

I am trying to deploy and I do not want the Gemfile.lock in version control. 我正在尝试部署,并且我不希望Gemfile.lock在版本控制中。 But when it's removed I get the following error. 但是,将其删除时,出现以下错误。

* executing "cd /var/www/vhosts/my-site/releases/20120628162217 && bundle install --       gemfile /var/www/vhosts/mysite/releases/20120628162217/Gemfile --path  /var/www/vhosts/my-site/shared/bundle --deployment --quiet --without development test cucumber  analytics"
    servers: ["staging-beta.my-site.com"]
[staging-beta.my-sitehealth.com] executing command
** [out :: staging-beta.my-site.com] The --deployment flag requires a Gemfile.lock.     Please make sure you have checked your Gemfile.lock into version control before deploying.
    command finished in 332ms

Here is my deploy.rb file: 这是我的deploy.rb文件:

require 'thinking_sphinx/deploy/capistrano'

set :rvm_ruby_string, '1.9.3'

# Ignore the .git directory when creating a release
set :copy_exclude, ".git*"

set :stages, %w(production staging rails_ec2_west_staging vagrant analytics highgroove ec2_highgroove stage_analytics ec2_staging highgroove_staging ec2_chef ec2_sphinx_chef solr_staging ec2_sphinx_prod_chef)
set :default_stage, "staging"

set :bundle_without, [:development, :test, :cucumber, :analytics]
require 'bundler/capistrano'
set :custom_symlinks, {}

require 'capistrano/ext/multistage'

if ARGV.first == 'ec2_staging'
  require 'rvm/capistrano'
  # for dual deploys on ec2 staging
  set :application, "my-site3"
else
  set :application, "my-site"
end

set :use_sudo, false
set :user, "www-data"
set :group, "www-data"

ssh_options[:forward_agent] = true

set :branch, $1 if `git branch` =~ /\* (\S+)\s/m

set :scm, :git
set :repository, "git@github.com:my-company/my-site3.git"
set :deploy_to, "/var/www/vhosts/#{application}"
set :deploy_via, :remote_cache
set :deploy_env, 'production'

# If you are using Passenger mod_rails uncomment this:
# if you're still using the script/reapear helper you will need
# these http://github.com/rails/irs_process_scripts

namespace :deploy do
   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

   task :seed, :roles => :db do
     rake = fetch(:rake, "rake")
     rails_env = fetch(:rails_env, "production")

     run "cd #{current_path} && #{rake} RAILS_ENV=#{rails_env} db:seed"
   end

end

namespace :assets do
  task :precompile do
    run "cd #{current_path} && #{rake} RAILS_ENV=#{rails_env} my-site-web:assets:precompile"
  end
end

task :uname do
  run "uname -a"
end

after "deploy:update", "deploy:cleanup"
after "deploy:update", "assets:precompile"

require './config/boot'
#require 'airbrake/capistrano'

It's the best practice to include the gemfile.lock. 包括gemfile.lock是最佳实践。 From Bundlers rational page: http://gembundler.com/rationale.html 从Bundlers有理页面: http ://gembundler.com/rationale.html

This is important: the Gemfile.lock makes your application a single package of both your own code and the third-party code it ran the last time you know for sure that everything worked. 这很重要:Gemfile.lock使您的应用程序既是您自己的代码又是第三方代码的单个包,它在您最后一次确定一切正常时运行。 Specifying exact versions of the third-party code you depend on in your Gemfile would not provide the same guarantee, because gems usually declare a range of versions for their dependencies. 在Gemfile中指定您依赖的第三方代码的确切版本不会提供相同的保证,因为gem通常会为其依赖项声明一系列版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM