Mac安裝rvm管理ruby版本,bundler管理gem版本

因?yàn)樽罱?xiàng)目中要用到不同版本的ruby,并且使用bundler來管理。然后,我又剛剛換了臺電腦,各種版本不匹配,各種傷感。把自己的經(jīng)驗(yàn)跟大家分享一下。

1、安裝rvm管理ruby因?yàn)楹竺嫘枰褂煤线m的ruby版本,所以需要運(yùn)用rvm來管理ruby版本。

(1)安裝rvm終端:curl -L https://get.rvm.io | bash -s stable期間可能會問你sudo管理員密碼,以及自動通過homebrew安裝依賴包,等待一段時間后就可以成功安裝好 RVM。然后,載入 RVM 環(huán)境(新開 Termal )

安裝成功提示:#? Thank you for using RVM!#? We sincerely hope that RVM helps to make your life easier and more enjoyable!!!

(2)檢測是否安裝成功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、檢測已知的ruby版本:? $ rvm list known

可能會出現(xiàn)下面的錯誤: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.

檢測成功: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......../

這個過程可能會耗費(fèi)相當(dāng)時間。時間太久了,

然后我選擇了執(zhí)行:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"跑得飛快,突然來了個急剎車HEAD is now at b38c52f Merge pull request #2289 from reitermarkus/cask-refactor-uninstall進(jìn)入更漫長的等待,當(dāng)然也有可能是我們公司無力吐槽的網(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的版本

此時選擇需要的版本:$ rvm use 2.3.0(我這需要使用2.3.0)Using /Users/MrLee/.rvm/gems/ruby-2.3.02、開始安裝bundler來管理多版本的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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容