我在配置 Sinatra 以使用 Bundler 时遇到问题。我对应该在哪里安装 Gems 感到困惑?我已经阅读了这个问题和这个文档。
我的Gemfile
样子:
source "http://rubygems.org"
gem "sinatra"
gem "amazon-ec2"
我的config.ru
样子:
require "rubygems"
require "bundler"
Bundler.setup
require "application"
run Sinatra::Application
我的application.rb
样子:
require "rubygems"
require "sinatra"
require "AWS"
#... rest of application
现在,当我运行bundle install
一切正常时,Gems 被安装到~/.bundle/
我的主目录中。然而,在我的应用程序中,如果我查看.bundle/config
它会显示:
---
BUNDLE_WITHOUT: ""
BUNDLE_PATH: vendor/gems
果然,当我启动应用程序(顺便使用Passenger)时,它说:
Could not find gem 'amazon-ec2 (>= 0, runtime)' in the gems available on this machine. (Bundler::GemNotFound)
显然bundle install
,Gems 安装在与 Sinatra 期望的位置不同的位置。这是否意味着我必须使用bundle install vendor
或重新配置其他东西,以便应用程序期望 Gems 在~/.bundle
?