美文网首页
Mac 安装 Ruby

Mac 安装 Ruby

作者: 顶宝麻麻 | 来源:发表于2019-08-21 23:46 被阅读0次
    1. 安装 gnupg
    brew install gnupg
    
    1. 安装 RVM
    官方推荐 :
    gpg –keyserver hkp://keys.gnupg.net –recv-keys
    409B6B1796C275462A1703113804BB82D39DC0E3
    

    但是报错:从公钥服务器接收失败:No route to host
    推荐离线下载步骤如下:

    // 离线包
    curl -sSL https://github.com/rvm/rvm/tarball/stable -o rvm-stable.tar.gz
    // 创建文件夹
    mkdir rvm && cd rvm
    // 解包
    tar --strip-components=1 -xzf ../rvm-stable.tar.gz
    // 安装 
    ./install --auto-dotfiles
    // 加载
    source ~/.rvm/scripts/rvm
    // if --path was specified when instaling rvm, use the specified path rather than '~/.rvm'
    

    RVM 安装 Ruby

    // 查询 ruby的版本
    rvm list known
    // 下载指定的版本(可能会出错failed status:1,再试一次)
    rvm install 2.4.2
    // 查询已安装ruby 版本
    rvm list
    // 卸载已安装版本
    rvm remove 2.x.x
    // 将系统的ruby切换为下载的版本
    rvm use 2.4.2  --default
    

    Ruby 的默认源使用的是 cocoapods.org,国内访问这个网址有时候会有问题

    // 删除 sources 
    gem source -r https://rubygems.org/
    // 添加 sources 
    gem source -a https://gems.ruby-china.com/
    // 查看 sources
    gem sources -l 
    // 结果如下:
    *** CURRENT SOURCES ***
    
    https://gems.ruby-china.com/
    

    参考文献:

    1. https://blog.csdn.net/tongwei117/article/details/79789111
    2. https://www.runoob.com/ruby/ruby-installation-unix.html

    相关文章

      网友评论

          本文标题:Mac 安装 Ruby

          本文链接:https://www.haomeiwen.com/subject/yrgwsctx.html