And*_*rew 16 capistrano ruby-on-rails bundler ruby-on-rails-4 capistrano3
我正在使用Capistrano 3和新生成的Rails 4应用程序.我的部署正在运行,但是当我bundle exec rails console在生产服务器上运行时,我收到来自Rails的警告:
看起来你的应用程序的./bin/rails是由Bundler生成的存根.
在Rails 4中,您的应用程序的bin /目录包含与任何其他源代码一样版本化的可执行文件,而不是按需生成的存根.
实际上,部署期间生成的binstub会覆盖存储库中的binstub:
原来的binstub:
$ cat bin/rails
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
Run Code Online (Sandbox Code Playgroud)
生产中的binstub:
$ cat bin/rails
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'rails' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../releases/20140930173754/Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('railties', 'rails')
Run Code Online (Sandbox Code Playgroud)
为了使Capistrano配置与Rails 4兼容,需要改变什么?
# Gemfile
group :development do
gem 'capistrano', '~> 3.1'
gem 'capistrano-rbenv', '~> 2.0'
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rails', '~> 1.1'
end
# config/deploy.rb
lock '3.2.1'
# ...
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
# ...
Run Code Online (Sandbox Code Playgroud)
其他一切都使用默认设置.
小智 33
由于./bin目录是在Rails 4中受版本控制,我们需要阻止Capistrano通过删除bin来在部署中链接它set :linked_dirs.现在,为了防止bundler覆盖版本控制的binstub,我们可以添加在运行bundle install时set :bundle_binstubs, nil阻止capistrano-bundler设置--binstubs选项的行.
希望有所帮助!
| 归档时间: |
|
| 查看次数: |
3902 次 |
| 最近记录: |