美文网首页
macOS | rvm升级ruby、nvm升级node

macOS | rvm升级ruby、nvm升级node

作者: SFHinc | 来源:发表于2023-03-09 16:46 被阅读0次

    使用rvm升级ruby

    mac系统内置ruby,不要卸载或更改系统内置的ruby,否则会导致mac系统故障!

    ruby -v

    //查看当前使用的版本
    ➜  ~ ruby -v
    ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
    

    rvm list known

    //列出所有已知版本
    ➜  ~ rvm list known
    Warning, new version of rvm available '1.29.12', you are using older version '1.29.9'.
    You can disable this warning with:   echo rvm_autoupdate_flag=0 >> ~/.rvmrc
    You can enable auto-update with:     echo rvm_autoupdate_flag=2 >> ~/.rvmrc
    You can update manually with:        rvm get VERSION                         (e.g. 'rvm get stable')
    
    # 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[.10]
    [ruby-]2.3[.8]
    [ruby-]2.4[.6]
    [ruby-]2.5[.5]
    [ruby-]2.6[.3]
    [ruby-]2.7[.0-preview1]
    ruby-head
    
    # for forks use: rvm install ruby-head-<name> --url https://github.com/github/ru
    by.git --branch 2.2
    
    # JRuby
    jruby-1.6[.8]
    jruby-1.7[.27]
    jruby-9.1[.17.0]
    jruby[-9.2.7.0]
    jruby-head
    
    # Rubinius
    rbx-1[.4.3]
    rbx-2.3[.0]
    rbx-2.4[.1]
    rbx-2[.5.8]
    rbx-3[.107]
    rbx-4[.3]
    rbx-head
    
    # TruffleRuby
    truffleruby[-19.1.0]
    
    # Opal
    opal
    
    # Minimalistic ruby implementation - ISO 30170:2012
    mruby-1.0.0
    mruby-1.1.0
    mruby-1.2.0
    mruby-1.3.0
    mruby-1[.4.1]
    mruby-2[.0.1]
    mruby[-head]
    
    
    # Ruby Enterprise Edition
    ree-1.8.6
    ree[-1.8.7][-2012.02]
    
    # Topaz
    topaz
    
    # MagLev
    maglev-1.0.0
    maglev-1.1[RC1]
    maglev[-1.2Alpha4]
    maglev-head
    
    # Mac OS X Snow Leopard Or Newer
    macruby-0.10
    macruby-0.11
    macruby[-0.12]
    macruby-nightly
    macruby-head
    
    # IronRuby
    ironruby[-1.1.3]
    ironruby-head
    

    rvm install [version]

    //安装指定版本
    ➜  ~ rvm install 2.6.3 
    Searching for binary rubies, this might take some time.
    No binary rubies available for: osx/12.6/x86_64/ruby-2.6.3.
    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 - please wait
    Installing required packages: zlib - please wait
    There were package installation errors, make sure to read the log.
    
    Try `brew tap --repair` and make sure `brew doctor` looks reasonable.
    
    Check Homebrew requirements https://docs.brew.sh/Installation
    Error running 'requirements_osx_brew_libs_install zlib',
    please read /Users/spark/.rvm/log/1678435056_ruby-2.6.3/package_install_zlib.log
    Requirements installation failed with status: 1.
    
    //如果出现上述错误执行下面的命令
    ➜  ~ rvm autolibs read-only
    //重新安装指定版本
    ➜  ~ rvm install 2.6.3 
    ...
    //等待安装完成
    

    rvm list

    //查看已安装的版本
    ➜  ~ rvm list
    =* ruby-2.5.1 [ x86_64 ]
       ruby-2.6.3 [ x86_64 ]
    
    # => - current
    # =* - current && default
    #  * - default
    

    rvm use ruby-[version] --default

    //查看使用版本
    ➜  ~ ruby -v
    ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
    
    //切换指定版本并设置为默认,每次启用都是用本版本
    ➜  ~ rvm use ruby-2.6.3 --default
    Using /Users/spark/.rvm/gems/ruby-2.6.3
    
    //查看使用版本
    ➜  ~ ruby -v                     
    ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin21]
    

    使用nvm升级node

    node -v

    //查看当前使用的版本
    ➜  ~ node -v
    v14.15.4
    

    nvm ls-remote

    //列出所有已知版本
    ➜  ~ nvm ls-remote
            v0.1.14
            v0.1.15
            v0.1.16
            ...
            v19.7.0
            v19.8.0
            v19.8.1
    

    nvm install [version]

    //安装指定版本
    ➜  ~ nvm install v19.8.1
    Downloading and installing node v19.8.1...
    Downloading https://nodejs.org/dist/v19.8.1/node-v19.8.1-darwin-x64.tar.xz...
    ######################################################################### 100.0%
    Computing checksum with shasum -a 256
    Checksums matched!
    Now using node v19.8.1 (npm v9.5.1)
    

    nvm list

    //查看已安装的版本
    ➜  ~ nvm list
             v14.15.4
             v16.19.0
    ->       v19.8.1
             system
    16.19.0 -> default (-> v16.19.0)
    default -> v16.19.0
    iojs -> N/A (default)
    unstable -> N/A (default)
    node -> stable (-> v19.8.1) (default)
    stable -> 19.8 (-> v19.8.1) (default)
    lts/* -> lts/hydrogen (-> N/A)
    lts/argon -> v4.9.1 (-> N/A)
    lts/boron -> v6.17.1 (-> N/A)
    lts/carbon -> v8.17.0 (-> N/A)
    lts/dubnium -> v10.24.1 (-> N/A)
    lts/erbium -> v12.22.12 (-> N/A)
    lts/fermium -> v14.21.3 (-> N/A)
    lts/gallium -> v16.19.1 (-> N/A)
    lts/hydrogen -> v18.15.0 (-> N/A)
    

    nvm use [version]

    //查看当前版本
    ➜  ~ node -v
    v14.15.4
    
    //使用指定版本
    ➜  ~ nvm use v16.19.0
    Now using node v16.19.0 (npm v8.19.3)
    
    //查看当前版本
    ➜  ~ node -v
    v16.19.0
    
    

    nvm alias default [version]

    //设置默认版本,每次启动终端都使用该版本
    ➜  ~ nvm alias default v16.19.0
    default -> v16.19.0
    

    相关文章

      网友评论

          本文标题:macOS | rvm升级ruby、nvm升级node

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