我正在使用我刚刚使用rails new
Rails 3.2.8 生成的骨架 Rails 应用程序配置新的生产部署设置。我在我的开发机器上使用 apache2 和 Phusion Passenger 进行了生产设置,一切正常。当我尝试将该配置推送到 EC2 时,资产预编译步骤失败,因为它找不到 jQuery。
宝石文件
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'capistrano'
gem 'jquery-rails'
gem 'haml'
group :assets do
gem 'less-rails'
gem 'uglifier', '>= 1.0.3'
gem 'therubyracer'
gem 'execjs'
end
group :deploy do
gem 'passenger'
end
group :production do
gem 'bigdecimal'
end
相关位deploy.rb
after "deploy:update_code" do
run "cd #{release_path}; rake assets:precompile RAILS_ENV=production "
end
输出
triggering after callbacks for `deploy:update_code'
* executing "cd /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008; rake assets:precompile RAILS_ENV=production"
servers: ["bww-test"]
[bww-test] executing command
** [out :: bww-test] /usr/bin/ruby1.9 /usr/local/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
** [out :: bww-test]
** [out :: bww-test] rake aborted!
** [out :: bww-test]
** [out :: bww-test] couldn't find file 'jquery'
** [out :: bww-test] (in /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008/app/assets/javascripts/application.js:13)
** [out :: bww-test]
** [out :: bww-test]
** [out :: bww-test] Tasks: TOP => assets:precompile:primary
** [out :: bww-test]
** [out :: bww-test] (See full trace by running task with --trace)
** [out :: bww-test]
** [out :: bww-test] rake aborted!
** [out :: bww-test] Command failed with status (1): [/usr/bin/ruby1.9 /usr/local/bin/rake asset...]
** [out :: bww-test]
** [out :: bww-test] Tasks: TOP => assets:precompile
** [out :: bww-test] (See full trace by running task with --trace)
command finished in 1819ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008; true"
servers: ["bww-test"]
[bww-test] executing command
command finished in 168ms
failed: "sh -c 'cd /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008; rake assets:precompile RAILS_ENV=production'" on bww-test
如果我查看服务器,Capistrano 已经安装了包含 jQuery 的包:
[ec2-user@ip-10-226-122-140 bw-widget]$ find . -name jquery\*
./shared/bundle/ruby/1.9.1/specifications/jquery-rails-2.1.3.gemspec
./shared/bundle/ruby/1.9.1/cache/jquery-rails-2.1.3.gem
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/jquery-rails.gemspec
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/lib/generators/jquery
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/lib/jquery
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/lib/jquery-rails.rb
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery_ujs.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery-ui.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery.min.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery-ui.min.js
./shared/bundle/ruby/1.9.1/gems/rdoc-3.12/lib/rdoc/generator/template/darkfish/js/jquery.js
ruby/1.9.1
当我实际使用 1.9.3p0(yum 安装版本,而不是 rvm 版本)时,我对 gems 的存在感到有些困惑,但我不知道这是否重要。
更新
根据Said的评论,我将 after update 任务更改为:
after "deploy:update_code" do
run "cd #{release_path}; bundle exec rake assets:precompile RAILS_ENV=production "
end
但是,我读过的所有文件都没有建议这bundle exec
是必要的,所以我仍然担心,虽然我有一个变通办法,但有些东西仍然没有完全正确配置。