因?yàn)樽罱?xiàng)目中要用到不同版本的ruby尺棋,并且使用bundler來(lái)管理封锉。然后,我又剛剛換了臺(tái)電腦膘螟,各種版本不匹配成福,各種傷感。把自己的經(jīng)驗(yàn)跟大家分享一下荆残。
1奴艾、安裝rvm管理ruby因?yàn)楹竺嫘枰褂煤线m的ruby版本,所以需要運(yùn)用rvm來(lái)管理ruby版本内斯。
(1)安裝rvm終端:curl -L https://get.rvm.io | bash -s stable期間可能會(huì)問(wèn)你sudo管理員密碼蕴潦,以及自動(dòng)通過(guò)homebrew安裝依賴(lài)包,等待一段時(shí)間后就可以成功安裝好 RVM俘闯。然后潭苞,載入 RVM 環(huán)境(新開(kāi) Termal )
安裝成功提示:#? Thank you for using RVM!#? We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
(2)檢測(cè)是否安裝成功a、$ rvm -v
RVM version 1.29.1 (latest) is installed yet 1.27.0 (latest) is loaded.Please do one of the following:* 'rvm reload'* open a new shell* 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.* 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.
(3)成功后安裝ruby
a真朗、檢測(cè)已知的ruby版本:? $ rvm list known
可能會(huì)出現(xiàn)下面的錯(cuò)誤:A RVM version? () is installed yet 1.25.14 (master) is loaded.Please do one of the following:* 'rvm reload'* open a new shell* 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.* 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.解決方案:sudo rm -rf /users/your_username/.rvmThen close and reopen the terminal.
檢測(cè)成功:MonsterdeMac-mini:~ MonsterLee$ rvm list known
# MRI Rubies[ruby-]1.8.6[-p420][ruby-]1.8.7[-head] # security released on head[ruby-]1.9.1[-p431][ruby-]1.9.2[-p330][ruby-]1.9.3[-p551][ruby-]2.0.0[-p648][ruby-]2.1[.10][ruby-]2.2[.6][ruby-]2.3[.3][ruby-]2.4[.0]ruby-headb萄传、
安裝ruby:執(zhí)行:$ rvm install 2.3.0Searching for binary rubies, this might take some time.No binary rubies available for: osx/10.11/x86_64/ruby-2.3.0.Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.Checking requirements for osx.Installing requirements for osx.Updating system......../
這個(gè)過(guò)程可能會(huì)耗費(fèi)相當(dāng)時(shí)間。時(shí)間太久了,
然后我選擇了執(zhí)行:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"跑得飛快秀菱,突然來(lái)了個(gè)急剎車(chē)HEAD is now at b38c52f Merge pull request #2289 from reitermarkus/cask-refactor-uninstall進(jìn)入更漫長(zhǎng)的等待振诬,當(dāng)然也有可能是我們公司無(wú)力吐槽的網(wǎng)速。
第一波比較明顯的反應(yīng):Installing requirements for osx.Updating system........
第二波比較明顯的反應(yīng):Installing required packages: autoconf, automake, libtool, pkg-config, coreutils, libyaml, readline, libksba, openssl..........
第三波比較明顯的反應(yīng):ruby-2.3.0 - #downloading ruby-2.3.0, this may take a while depending on your connection...ruby-2.3.0 - #extracting ruby-2.3.0 to /Users/MrLee/.rvm/src/ruby-2.3.0....ruby-2.3.0 - #applying patch /Users/MrLee/.rvm/patches/ruby/changeset_r53419.diff.ruby-2.3.0 - #configuring......................................................|ruby-2.3.0 - #post-configuration.ruby-2.3.0 - #compiling................................ruby-2.3.0 - #installing.........ruby-2.3.0 - #making binaries executable..ruby-2.3.0 - #downloading rubygems-2.6.10
到此衍菱,終于在電腦上成功的配置了2.3.0的版本
此時(shí)選擇需要的版本:$ rvm use 2.3.0(我這需要使用2.3.0)Using /Users/MrLee/.rvm/gems/ruby-2.3.02赶么、開(kāi)始安裝bundler來(lái)管理多版本的gemMonSter:~ MrLee$ gem install bundlerFetching: bundler-1.14.6.gem (100%)Successfully installed bundler-1.14.6Parsing documentation for bundler-1.14.6Installing ri documentation for bundler-1.14.6Done installing documentation for bundler after 8 seconds1 gem installedgem
3、項(xiàng)目中安裝bundle及相關(guān)操作
PROJECT $ bundle install
Installing fastlane 2.9.0Bundle complete! 2 Gemfile dependencies, 74 gems now installed.Use `bundle show [gemname]` to see where a bundled gem is installedMonSter:
PROJECT MrLee$ bundle exec pod install --no-repo-update