EC2上的资产预编译失败:无法找到jQuery

时间:2012-10-17 10:02:52

标签: ruby-on-rails ruby amazon-ec2 capistrano

我正在使用骨架rails应用程序配置新的生产部署设置,我刚刚使用带有Rails 3.2.8的rails new生成了该应用程序。我的dev机器上有一个生产设置,有apache2和Phusion Passenger,一切正常。当我尝试将该配置推送到EC2时,资产预编译步骤失败,因为它无法找到jQuery。

的Gemfile

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

当我实际使用1.9.3p0(yum安装版本,而不是rvm版本)时,我有点疑惑地认为这些宝石在ruby/1.9.1,但我不知道这是否有意义。

更新

根据Said的评论,我将更新后的任务更改为:

after "deploy:update_code" do
  run "cd #{release_path}; bundle exec rake assets:precompile RAILS_ENV=production "
end

但是,我读过的文件都没有提出bundle exec是必要的,所以我仍然担心,虽然我有一个解决办法,但仍然没有正确配置。< / p>

0 个答案:

没有答案