2011-02-24 93 views
0

我已经将sinatra应用程序war and并部署在glassfish上。我用bundler来管理依赖关系,warbler已经将这些gem包含在WEB-INF/gems目录中。Rakefile没有看到war 0123的宝石

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

[email protected]:~/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) 

[email protected]:~/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 
+0

在我的rakefile中引用Bundler.setup并从那里试图要求'sinatra'gem,但不知道为什么gem不可用于rakefile或bundler – 2011-02-24 20:57:26

回答

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