0

我在 glassfish 上部署了 sinatra 应用程序。我使用 bundler 来管理依赖项,warbler 已将这些 gem 包含在 WEB-INF/gems 目录中。

但是当我尝试从 WEB-INF 目录运行 rake 任务时,该任务没有运行。

gfish@server2:~/glassfish/domains/domain1/applications/sinatra_app/WEB-INF$ rake resque:work
(in /home/gfish/glassfish/domains/domain1/applications/sinatra_app/WEB-INF)
rake aborted!
Could not find gem 'sinatra (>= 0, runtime)' in any of the gem sources listed in your Gemfile.
/home/gfish/glassfish/domains/domain1/applications/sinatra_app/WEB-INF/Rakefile:5:in `(root)'
(See full trace by running task with --trace)

gfish@server2:~/glassfish/domains/domain1/applications/sinatra_app/WEB-INF$ **ls -l** gems/gems/
total 104
...
drwxr-xr-x 4 root root 4096 2011-02-24 14:38 sinatra-1.1.3
4

1 回答 1

0

我终于找到了。我使用下面的代码来做到这一点。

# Add warbled gems to the $LOAD_PATH
if ENV['RACK_ENV'] == "production"
  puts "Adding warbled gems to the load path..."
  local_gems_path = Dir[File.expand_path(".") + "/gems/gems/*"]
  local_gems_path.each do |g|
    $LOAD_PATH.unshift "#{g}/lib/"
  end
end
于 2011-03-16T22:52:10.520 回答