我第一次使用 Capistrano 部署应用程序,这是我在 Rails 4 / Capistrano 中的第一个应用程序,在 lib 文件夹中有一个自定义类。
我在部署时收到以下错误:
* executing "cd -- /u/apps/focus/releases/20130917152233 && RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile"
servers: ["focus"]
[focus] executing command
*** [err :: focus] rake aborted!
*** [err :: focus] cannot load such file -- VSphere
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
*** [err :: focus] /u/apps/focus/releases/20130917152233/lib/tasks/usage.rake:3:in `block in <top (required)>'
*** [err :: focus] /u/apps/focus/releases/20130917152233/lib/tasks/usage.rake:1:in `<top (required)>'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:641:in `block in run_tasks_blocks'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:641:in `each'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:641:in `run_tasks_blocks'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:244:in `run_tasks_blocks'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:446:in `load_tasks'
*** [err :: focus] /u/apps/focus/shared/bundle/ruby/1.9.1/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
*** [err :: focus] /u/apps/focus/releases/20130917152233/Rakefile:6:in `<top (required)>'
*** [err :: focus] (See full trace by running task with --trace)
command finished in 4490ms
*** [deploy:update_code] rolling back
我有一个名为 usage.rake 的 rake 文件,它需要在任务顶部使用 VSphere 库:
namespace :usage do
desc "Tasks related to the usage application"
require 'VSphere'
..snip..
end
所以我知道我的 rake 任务需要该文件,当我在开发中运行 rake 任务时它工作得很好。
所以两个问题:
- 为什么资产管道正在寻找 ruby 库作为依赖项?就 Javascript 或样式表而言,它不适合作为“资产”。
- 如何让管道识别此要求不是 gem,并且 ruby 文件存在于 lib 文件夹中?
假设答案 #1:我相信资产管道正在查看我的 rake 任务的 require 语句,因为它可能包含可以预编译的 javascript 或样式表。在这种情况下,它不会。我仍在寻找一种方法来避免这种“依赖”或将资产管道指向自定义库的正确方向。
任何指导将不胜感激!谢谢!
编辑:澄清了两个问题并消除了与其他依赖项的混淆。