[英]How to specify rvm gemsets for Rails gem whenever?
MyApp使用的是rvm gemset 1.9.3@rails-3.2。 这不是默认值。
我正在使用gem“无论何时”来定期发送电子邮件通知。 这是我的schedule.rb:
every 1.minutes do
runner "MyModel.send_emails" # if ...
end
除非默认使用gemset 1.9.3@rails-3.2,否则Cron作业将无法正常工作。 我如何改善我的schedule.rb以便为我的scheduller使用另一个gemset(不仅是默认的@global)。
我已经阅读了官方文档: 每当和rvm问题以及关于“何时使用rvm gemsets”的stackoverflow问题,但没有找到答案。
我试图将以下代码(根据RVM-Notes中的建议)放在我的shedule.rb中:
job_type :runner, "{ cd #{@current_path} > /home/####/.rvm/gems/ruby-1.9.3-p448@
rails-3.2/bin/rails; } && RAILS_ENV=:environment bundle exec rails runner ':task' :output"
但是没有结果:
ERROR:
/home/###/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92
:in `block in materialize': Could not find i18n-0.6.5 in any of the sources
(Bundler::GemNotFound)
如何为“何时”为Rails gem指定rvm gemset? 非常感谢!
UPDATE
1)我试图为我的Gemfile提供rvm注意:
ruby=ruby-1.9.3-p448 # with # sign
ruby-gemset=rails-3.2 # with # sign
没有任何结果。 没有什么变化。
2)我试图修改我的〜/ .rvmrc。 实验了完整的捆绑路径,rails给了我以下错误列表:
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/usr/bin/env: ruby_executable_hooks/usr/bin/env: ruby_executable_hooks: No such file or directory
: No such file or directory
这里通过job_type实验:
#job_type :runner, "{ cd #{path}; } && RAILS_ENV=:environment bundle exec rails runner ':task' :output"
job_type :runner, "{ cd #{path}; } && RAILS_ENV=:environment /home/###/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle exec rails runner ':task' :output"
#job_type :runner, "cd #{path} && RAILS_ENV=development /home/###/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle exec /home/###/.rvm/gems/ruby-1.9.3-p448@rails-3.2/bin/rails runner ':task' :output"
使用包装器:
job_type :runner, "cd #{path} && RAILS_ENV=development /home/###/.rvm/wrappers/ruby-1.9.3-p448@rails-3.2/bundle exec rails runner ':task' :output"
这将加载正确的rvm环境并在其上下文中运行bundle
,bundler仅添加环境变量以使用来自Gemfile
gem,而不修改加载的ruby环境。
此处描述了类似情况http://rvm.io/integration/init-d
尝试
job_type :runner, "cd :path && RAILS_ENV=:environment bundle exec rails runner :task :output"
假设您在Gemfile
提到了
#ruby=ruby-1.9.3-p448
#ruby-gemset=rails-3.2
有关此符号,请参见RVM文档 。
尝试在项目根目录中创建.rvmrc文件,并包含以下行
rvm use 1.9.3@rails-3.2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.