bundle init 命令在當前目錄下生存Gemfile文件。
默認情況下,執行bundle install的時候,自動去Gemfile中的sources中去下載gem。
如果你的gem需要從私有gem server 獲取 使用source
gem 'my_gem', '1.0', :source => 'https://gems.example.com'
如果,多個gem需要從相同的server獲取使用source塊組織
source 'https://gems.example.com' do
gem 'my_gem', '1.0'
gem 'another_gem', '1.2.1'
end
- 使用git repositories 作為source。使用':tag'、':branch'、'ref'聲明需要檢出的分支,默認的是msater分支。
gem 'nokogiri', :git => 'https://github.com/tenderlove/nokogiri.git', :branch => '1.4'
- 直接使用文件系統未打包的gem, 使用path
gem 'extracted_library', :path => './vendor/extracted_library'
如果你想直接使用你文件系統中(你當前使用的操作系統)的多個gem,設置一個全局的'path'參數,將自動加載.
path 'components' do
gem 'admin_ui'
gem 'public_ui'
end