我已经尝试了很多不同的方法来做到这一点并找到了让它运行起来的黑客攻击,但我正在努力确保我正确地做到这一点。我正在运行Rails 4.1.9,并且我已经从build_missing_paperclip_styles复制了代码,当我部署时,我得到一个错误,说" bundle:command not found"。我已经粘贴了堆栈跟踪。
如果我更改此行
execute "cd #{current_path}; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles"
到这一行:
execute "cd #{current_path}; RAILS_ENV=production $HOME/.rbenv/bin/rbenv exec bundle exec rake paperclip:refresh:missing_styles"
它有效。但是部署期间的其他命令与bundle和rake一起工作正常,那么为什么不选择这个呢?
这是相关的堆栈跟踪:
DEBUG [c7e11673] Command: cd /home/ec2-user/code/current; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles
DEBUG [c7e11673] bash: bundle: command not found
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as ec2-user@example.com: cd /home/ec2-user/code/current; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles exit status: 127
cd /home/ec2-user/code/current; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles stdout: Nothing written
cd /home/ec2-user/code/current; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles stderr: bash: bundle: command not found
SSHKit::Command::Failed: cd /home/ec2-user/code/current; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles exit status: 127
cd /home/ec2-user/code/current; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles stdout: Nothing written
cd /home/ec2-user/code/current; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles stderr: bash: bundle: command not found
Tasks: TOP => deploy:build_missing_paperclip_styles
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as ec2-user@example.com: cd /home/ec2-user/code/current; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles exit status: 127
cd /home/ec2-user/code/current; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles stdout: Nothing written
cd /home/ec2-user/code/current; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles stderr: bash: bundle: command not found
`