我尝试在我的 Ubuntu 14.04 服务器中设置 gem。在我的本地机器上它工作正常。我使用 capistrano 来部署站点。我在服务器中使用 rbenv。但是在安装乘客时,它会安装我不使用的 Ruby 1.9。仅使用 rbenv。这是我的 shcedule.rb :
set :output, "#{path}/log/cron.log"
every 30.minutes do
runner 'UploadmailWorker.perform_async'
end
every 12.hours do
runner 'SubscriptionWorker.perform_async'
end
every :month do
runner 'PaysellerWorker.perform_async'
end
我的 deploy.rb :
set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}
set :whenever_roles, ->{ :app }
set :whenever_command, ->{ [:bundle, :exec, :whenever] }
set :whenever_command_environment_variables, ->{ {} }
set :whenever_identifier, ->{ fetch :application }
set :whenever_environment, ->{ fetch :rails_env, fetch(:stage, "production") }
set :whenever_variables, ->{ "environment=#{fetch :whenever_environment}" }
set :whenever_update_flags, ->{ "--update-crontab #{fetch :whenever_identifier} --set #{fetch :whenever_variables}" }
set :whenever_clear_flags, ->{ "--clear-crontab #{fetch :whenever_identifier}" }
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
end
部署后,无论何时都不起作用。在 cron.log 我发现这个错误:
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/deploy/istockseller/releases/20150519112817/config/boot.rb:3:in `<top (required)>'
from bin/rails:7:in `require_relative'
from bin/rails:7:in `<main>'
我该如何解决?