Opsworks : cron : Ruby 版本不正确

Posted

技术标签:

【中文标题】Opsworks : cron : Ruby 版本不正确【英文标题】:Opsworks : cron : Ruby version is incorrect 【发布时间】:2015-02-23 20:42:10 【问题描述】:

我的目标是设置一个 cron 条目以在我的 Opsworks rails 应用程序层上运行 rake 任务。 我关注了AWS doco on this subject found here

我的厨师工作:

cron_env = "PATH" => "/usr/local/bin:$PATH"
cron "warm up the cache" do
  environment cron_env
  hour "5"
  minute "10"
  command "cd /srv/www/myapp/current && RAILS_ENV=production bundle exec rake cache:warm_api"
end

实例上的 crontab:

user@myinstance:~$ sudo crontab -l -u root
# Chef Name: warm up the cache
PATH=/usr/local/bin:$PATH
10 5 * * * cd /srv/www/myapp/current && RAILS_ENV=production bundle exec rake cache:warm_api

我在 /usr/local/bin 中的 ruby​​ -v:

user@myinstance:~$ /usr/local/bin/ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

问题:

在执行期间,我的 cron 未能使用正确的 ruby​​。

/usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/definition.rb:385:in `validate_ruby!': Your Ruby version is 1.9.3, but your Gemfile specified 2.1.2 (Bundler::RubyVersionMismatch)
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler.rb:117:in `setup'
    from /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/setup.rb:17:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require

【问题讨论】:

【参考方案1】:

结果证明这是 Opsworks 中的临时故障。

【讨论】:

以上是关于Opsworks : cron : Ruby 版本不正确的主要内容,如果未能解决你的问题,请参考以下文章