bundle install的作用:Make sure all dependencies in yourGemfileare available to your application.
尤其是你切換環(huán)境(切換不同的系統(tǒng)),這個(gè)時(shí)候在新的環(huán)境中可能各個(gè)Gem組件的版本不匹配,就需要運(yùn)行bundle Install來(lái)保證當(dāng)前環(huán)境的GEM FILES版本匹配。
[ruby]view plaincopy
$?bundle?install?[--binstubs=PATH]?[--clean]?[--deployment]?[--frozen]
[--full-index]?[--gemfile=FILE]?[--local]?[--no-cache]
[--no-prune]?[--path=PATH]?[--quiet]?[--shebang=STRING]
[--standalone=ARRAY]?[--system]?[--without=GROUP?GROUP]
Options:
--binstubs: Generate bin stubs for bundled gems to ./bin
--clean: Run bundle clean automatically after install
--deployment: Install using defaults tuned for deployment environments
--frozen: Do not allow the Gemfile.lock to be updated after this install
--full-index: Use the rubygems modern index instead of the API endpoint
--gemfile: Use the specified gemfile instead of Gemfile
--local: Do not attempt to fetch gems remotely and use the gem cache instead
--no-cache: Don't update the existing gem cache.
--no-prune: Don't remove stale gems from the cache.
--path: Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine
--quiet: Only output warnings and errors.
--shebang: Specify a different shebang executable name than the default (usually 'ruby')
--standalone: Make a bundle that can work without the Bundler runtime
--system: Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application
--without: Exclude gems that are part of the specified named group.
rails new時(shí)bundle install有的時(shí)候非常慢
rails new xxx創(chuàng)建一個(gè)新項(xiàng)目,常常會(huì)卡在“run? bundle install”,有的時(shí)候快點(diǎn),有的時(shí)候非常慢
C:\Work>rails new ptian1
create
create? README.rdoc
create? Rakefile
...
...
create? vendor/plugins/.gitkeep
run? bundle install
這是因?yàn)閞ails new時(shí)自動(dòng)會(huì)運(yùn)行bundle install,而bundle install會(huì)自動(dòng)去rubygems.org查找是否有更新。但需要的gems我早安裝好了,且不用更新,所以上面步驟就可省了。強(qiáng)烈建議rails黨委取消rails new時(shí)自動(dòng)查找gems更新功能!
解法很簡(jiǎn)單
rails new my_app --skip-bundle
cd my_app
bundle install --local
另外,最新版bundler速度提高不少,建議使用,也能提速
gem install bundler --pre