【发布时间】:2014-09-27 12:54:14
【问题描述】:
我的 Capistrano 部署在运行 bundle 命令时没有设置 RAILS_ENV 变量。我不明白为什么。
我的 Gemfile 是:
source 'https://rubygems.org'
ruby '2.1.3'
gem 'capistrano', '~> 3.2.1'
gem 'capistrano-rails', '~> 1.1.1'
我的 deploy.rb :
set :stage, :production
set :rails_env, 'production'
set :bundle_flags, '--deployment'
set :bundle_env_variables, { rails_env: "production" }
namespace :sphinx do
desc "Index Sphinx"
task :index do
on roles(:app) do
within release_path do
execute :rake, "rake ts:index"
end
end
end
运行时:
➜ ansible-sharetribe git:(master) ✗ bin/cap production sphinx:index --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_rails_env
** Invoke sphinx:index (first_time)
** Execute sphinx:index
INFO[3ca70ab5] Running bundle exec rake rake ts:index on www.myapplication.com
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host www.myapplication.com: rake exit status: 1
rake stdout: Nothing written
rake stderr: Digest::Digest is deprecated; use Digest
rake aborted!
NameError: uninitialized constant Annotate
如果我写:
execute :rake, "rake ts:index RAILS_ENV=production"
它有效。为什么没有自动设置 RAILS_ENV=production?
【问题讨论】:
-
你找到答案了吗?看起来我遇到了同样的问题......
-
我也有同样的问题。遇到了很多修复,但都没有奏效。
标签: ruby-on-rails capistrano capistrano3