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

因为最近项目中要用到不同版本的ruby,并且使用bundler来管理。然后,我又刚刚换了台电脑,各种版本不匹配,各种伤感。把自己的经验跟大家分享一下。

1、安装rvm管理ruby因为后面需要使用合适的ruby版本,所以需要运用rvm来管理ruby版本。

(1)安装rvm终端:curl -L https://get.rvm.io | bash -s stable期间可能会问你sudo管理员密码,以及自动通过homebrew安装依赖包,等待一段时间后就可以成功安装好 RVM。然后,载入 RVM 环境(新开 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

可能会出现下面的错误: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:执行:$ 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......../

这个过程可能会耗费相当时间。时间太久了,

然后我选择了执行: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进入更漫长的等待,当然也有可能是我们公司无力吐槽的网速。

第一波比较明显的反应:Installing requirements for osx.Updating system........

第二波比较明显的反应:Installing required packages: autoconf, automake, libtool, pkg-config, coreutils, libyaml, readline, libksba, openssl..........

第三波比较明显的反应: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、项目中安装bundle及相关操作

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

你可能感兴趣的:(Mac安装rvm管理ruby版本,bundler管理gem版本)