当前位置:首页 > 软件应用 > 正文

Ruby、RVM

摘要: Ruby、RVM最佳答案53678位专家为你答疑解惑Ruby、RVM-使用总结Ruby、RVM-使用总结安装或更新Ruby方法一...

Ruby、RVM

最佳答案 53678位专家为你答疑解惑

Ruby、RVM-使用总结

Ruby、RVM-使用总结安装或更新Ruby方法一:使用Homebrew安装RubyHomebrew 是什么:

Homebrew是 mac的包管理器,仅需执行相应的命令,就能下载安装需要的软件包,可以省掉自己去下载、解压、拖拽(安装)等繁琐的步骤。

Homebrew 官方文档

安装Homebrew

在终端执行:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

执行结果:

==> Checking for `sudo` access (which may request your password).Password:==> This script will install:/opt/homebrew/bin/brew/opt/homebrew/share/doc/homebrew/opt/homebrew/share/man/man1/brew.1/opt/homebrew/share/zsh/site-functions/_brew/opt/homebrew/etc/bash_completion.d/brew/opt/homebrewPress RETURN to continue or any other key to abort==> /usr/bin/sudo /usr/sbin/chown -R hsh:admin /opt/homebrew==> Downloading and installing Homebrew...HEAD is now at 976f9daa1 Merge pull request #12235 from Homebrew/dependabot/bundler/Library/Homebrew/sorbet-0.5.9226fatal: Could not resolve HEAD to a revisionWarning: /opt/homebrew/bin is not in your PATH.  Instructions on how to configure your shell for Homebrew  can be found in the 'Next steps' section below.==> Installation successful!==> Homebrew has enabled anonymous aggregate formulae and cask analytics.Read the analytics documentation (and how to opt-out) here:  https://docs.brew.sh/AnalyticsNo analytics data has been sent yet (or will be during this `install` run).==> Homebrew is run entirely by unpaid volunteers. Please consider donating:  https://github.com/Homebrew/brew#donations==> Next steps:- Run these two commands in your terminal to add Homebrew to your PATH:    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/hsh/.zprofile    eval "$(/opt/homebrew/bin/brew shellenv)"- Run `brew help` to get started- Further documentation:     https://docs.brew.sh

可以看到第一步执行后有报错,按照报错提示执行Next steps:在终端执行:

// 第一步echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/hsh/.zprofile// 第二步eval "$(/opt/homebrew/bin/brew shellenv)"

注:Mac M1 芯片每次重新打开终端时,可能无法找到brew,按照报错提示执行,重新打开终端时,也无法找到,解决办法:可以在终端执行:

// 用echo 添加上导出语句echo 'export PATH="/opt/homebrew/bin:$PATH"' >> $HOME/.zshrc// 运行source命令,文件生效source ~/.zshrc

启动brew,在终端执行:brew help

执行结果:

Example usage:  brew search TEXT|/REGEX/  brew info [FORMULA|CASK...]  brew install FORMULA|CASK...  brew update  brew upgrade [FORMULA|CASK...]  brew uninstall FORMULA|CASK...  brew list [FORMULA|CASK...]Troubleshooting:  brew config  brew doctor  brew install --verbose --debug FORMULA|CASKContributing:  brew create URL [--no-fetch]  brew edit [FORMULA|CASK...]Further help:  brew commands  brew help [COMMAND]  man brew  https://docs.brew.sh

在终端执行:brew -v:查看最新版本:

执行结果:

Homebrew 3.2.16Homebrew/homebrew-core (no Git repository)
更新Homebrew

打开终端执行:brew update

执行结果:

Already up-to-date.
Homebrew常用语法:
// 卸载Homebrew/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"// 查询:brew search 软件名    // 安装:brew install 软件名    // 卸载:brew uninstall 软件名    // 更新 Homebrew自己:brew update     // 查看 Homebrew 配置信息:brew config     // 查看哪些安装包需要更新brew outdated    // 更新安装包brew upgrade   # 更新所有的包brew upgrade $FORMULA   # 更新指定的包    // 清理旧版本brew cleanup   # 清理所有包的旧版本brew cleanup $FORMULA   # 清理指定包的旧版本brew cleanup -n   # 查看可清理的旧版本包,不执行实际操作    // 锁定不想更新的包brew pin $FORMULA   # 锁定某个包brew unpin $FORMULA    # 取消锁定    // 查看安装包的相关信息brew info $FORMULA   # 显示某个包的信息brew info   # 显示安装了包数量,文件数量,和总占用空间brew deps --installed --tree   # 查看已安装的包的依赖,树形显示    // 列出已安装包brew list    // 删除brew rm $FORMULA   # 删除某个包brew uninstall --force $FORMULA   # 删除所有版本

注:Homebrew主要由四个部分组成:brewhomebrew-corehomebrew-caskhomebrew-bottles,它们对应的功能如下:

组成功能Homebrew源代码仓库homebrew-coreHomebrew 核心源homebrew-cask提供macos应用和大型二进制文件的安装homebrew-bottles预编译二进制软件包安装或更新Ruby

先更新Homebrewbrew update;Mac自身的ruby版本是2.6.3p62

安装rubybrew install ruby

执行结果:

==> Downloading https://ghcr.io/v2/homebrew/core/libyaml/manifests/0.2.5######################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/libyaml/blobs/sha256:fe1082f347==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh######################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2021-######################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:47==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh######################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1l_1######################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:e3d855==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh######################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/readline/manifests/8.1.1######################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/readline/blobs/sha256:bcb228b99==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh######################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/ruby/manifests/3.0.2_1######################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/ruby/blobs/sha256:86f9be3f7ac26==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh######################################################################## 100.0%==> Installing dependencies for ruby: libyaml, ca-certificates, openssl@1.1 and readline==> Installing ruby dependency: libyaml==> Pouring libyaml--0.2.5.arm64_big_sur.bottle.tar.gz

发表评论