写写代码,聊聊生活

0%

记录一次在 Mac 下安装 Ruby 遇到的坑

最近在新的 Mac 中安装 Ruby 过程中,遇到的一些坑,记录一下

安装 rvm

1
$ curl -L https://get.rvm.io | bash -s stable

用 rvm 安装 Ruby 环境

  • 列出已知的ruby版本
1
$ rvm list known
  • 安装对应版本
1
$ rvm install 2.7

在安装过程中出现
requirements_osx_brew_libs_install 安装依赖包错误,日志如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[2020-03-11 17:30:00] requirements_osx_brew_libs_install
requirements_osx_brew_libs_install ()
{
brew install "$@" --force || {
\typeset ret=$?;
requirements_osx_brew_libs_error "installation";
return $ret
}
}
current path: /Users/ianyumi
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS:/Users/ianyumi/.rvm/bin
command(3): requirements_osx_brew_libs_install coreutils libyaml
++ brew install coreutils libyaml --force
Error: coreutils 8.28 is already installed
To upgrade to 8.32, run `brew upgrade coreutils`.
Error: libyaml 0.1.7 is already installed
To upgrade to 0.2.2, run `brew upgrade libyaml`.
++ typeset ret=1
++ requirements_osx_brew_libs_error installation
++ rvm_warn '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'
++ rvm_pretty_print stderr
++ case "${rvm_pretty_print_flag:=auto}" in
++ case "${TERM:-dumb}" in
++ case "$1" in
++ [[ -t 2 ]]
++ return 1
++ printf %b '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\n'
++ return 1

根据日志提示,依次执行以下命令

1
2
$ brew upgrade coreutils
$ brew upgrade libyaml

执行完后,可以正常安装依赖包了,但是在Ruby编译过程中又报错了,通过查看make.log文件,搜索error关键字,得出

1
fatal error: 'plist/Node.h' file not found

通过Google这个报错信息,在这里有解决方案了

依次执行以下命令即可

1
2
3
4
$ brew doctor
$ brew doctor 2> doctor.txt
$ sed 's/^ //g' doctor.txt | tr "\n" "\0" | xargs -0 rm
rm doctor.txt

至此,安装成功
如果遇到的是其他错误,看日志吧,日志是个好东西