[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$f6-Pc-cl1FlrXgxD6yirb1cWORpmAIsxtY7UZfj_tuU4":3},{"code":4,"message":5,"data":6},200,"成功",{"id":7,"createdAt":8,"title":9,"content":10,"summary":11,"image":12,"uid":13,"user":14,"categoryId":21,"category":22,"subCategoryId":24,"subCategory":25,"comments":27,"status":17,"reason":28,"notice":28,"visitCount":29,"commentCount":30,"keywords":31},169,"2025-09-20T11:18:11.125Z","rvm install ruby-3.2.2 failed: Error running 'requirements_osx_brew_update_system ruby-3.2.2'","最近换了电脑，所以又需要配置一下电脑的环境，但是在遇到ruby环境的升级时又遇到了新的问题，所以在此记录一下。\n\n在我之前的文章：[https://www.xinwei.ltd/article/87](https://www.xinwei.ltd/article/87)中，已经描述了如何在mac中安装rvm来管理ruby版本的流程和步骤。\n\n但是一些异常情况仍然可能会出现，因为电脑系统版本等问题，这里出现的就是其中一种。\n\n## 问题\n> ➜  ~ sudo rvm install ruby-3.2.2 --verbose\nSearching for binary rubies, this might take some time.\nNo binary rubies available for: osx/26.0/x86_64/ruby-3.2.2.\nContinuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.\nChecking requirements for osx.\nInstalling requirements for osx.\nUpdating system..........Failed to update Homebrew, follow instructions at\n.\n    https://docs.brew.sh/Common-Issues\n>\n> and make sure `brew update` works before continuing.\n.\nError running 'requirements_osx_brew_update_system ruby-3.2.2',\nplease read /Users/hamry/.rvm/log/1758364524_ruby-3.2.2/update_system.log\nRequirements installation failed with status: 1.\n\n\n截图：\n![ruby error](https://image.xinwei.ltd/image1758365862537.png)\n\n正如报错中所示，说没有更新Homebrew，但是当我执行`brew update`命令时，提示当前的Homebrew已经是最新版本。\n![brew version](https://image.xinwei.ltd/image1758366123908.png)\n\n所以肯定是由其他问题导致的，那我们打开报错中的log文件，看能不能找到具体问题：\n```update_system.log\n[2025-09-20 18:35:24] requirements_osx_brew_update_system\nrequirements_osx_brew_update_system () \n{ \n    if __rvm_version_compare \"${_system_version}\" -ge 10.7; then\n        __rvm_detect_xcode_version_at_least 4.6.2 || __CLT_version_at_least 4.6.0 || { \n            \\typeset ret=$?;\n            rvm_error \"\nXcode version older than 4.6.2 installed, download and install newer version from:\n\n    http://connect.apple.com\n\nAfter installation open Xcode, go to Downloads and install Command Line Tools.\n\";\n            return $ret\n        };\n    fi;\n    brew update || { \n        \\typeset ret=$?;\n        rvm_error \"Failed to update Homebrew, follow instructions at\n\n    https://docs.brew.sh/Common-Issues\n\nand make sure \\`brew update\\` works before continuing.\";\n        return $ret\n    }\n}\ncurrent path: /Users/hamry\nPATH=/Users/hamry/.nvm/versions/node/v22.19.0/bin:/Users/hamry/env_packages/flutter/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/hamry/.rvm/bin\ncommand(2): requirements_osx_brew_update_system ruby-3.2.2\n++ __rvm_version_compare 26.0 -ge 10.7\n++ typeset first\n+++ command printf %b '26.0\\n10.7\\n'\n+++ printf %b '26.0\\n10.7\\n'\n+++ __rvm_version_sort\n+++ command head -n1\n+++ head -n1\n+++ command awk '-F[.-]' -v OFS=. '{                   # split on \".\" and \"-\", merge back with \".\"\n    original=$0                                        # save original to preserve it before the line is changed\n    for (n=1; n\u003C10; n++) {                             # iterate through max 9 components of version\n      $n=tolower($n)                                   # ignore case for sorting\n      if ($n == \"\")                 $n=\"0\"             # treat non existing parts as 0\n      if ($n ~ /^p[0-9]/)           $n=substr($n, 2)   # old ruby -p notation\n      if ($n ~ /^[0-9](rc|b)/)      $n=substr($n, 1, 1)\". \"substr($n, 2)   # old jruby 0RC1 notation\n      if (n == 1 && $n ~ /^[0-9]/)  $n=\"zzz.\"$n        # first group must be a string\n      if (n > 1 && $n ~ /^[a-z]/)   $n=\" \"$n           # names go before numbers thanks to space\n    }\n    print $0\"\\t\"original                               # print the transformed version and original separated by \\t\n                                                       # so we can extract original after sorting\n  }'\n+++ awk '-F[.-]' -v OFS=. '{                   # split on \".\" and \"-\", merge back with \".\"\n    original=$0                                        # save original to preserve it before the line is changed\n    for (n=1; n\u003C10; n++) {                             # iterate through max 9 components of version\n      $n=tolower($n)                                   # ignore case for sorting\n      if ($n == \"\")                 $n=\"0\"             # treat non existing parts as 0\n      if ($n ~ /^p[0-9]/)           $n=substr($n, 2)   # old ruby -p notation\n      if ($n ~ /^[0-9](rc|b)/)      $n=substr($n, 1, 1)\". \"substr($n, 2)   # old jruby 0RC1 notation\n      if (n == 1 && $n ~ /^[0-9]/)  $n=\"zzz.\"$n        # first group must be a string\n      if (n > 1 && $n ~ /^[a-z]/)   $n=\" \"$n           # names go before numbers thanks to space\n    }\n    print $0\"\\t\"original                               # print the transformed version and original separated by \\t\n                                                       # so we can extract original after sorting\n  }'\n+++ LC_ALL=C\n+++ sort -t. -k 1,1d -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n\n+++ awk '-F\\t' '{print $2}'\n++ first=10.7\n++ case \"$2\" in\n++ [[ 10.7 == \\h\\e\\a\\d ]]\n++ [[ 10.7 == \\1\\0\\.\\7 ]]\n++ return 0\n++ __rvm_detect_xcode_version_at_least 4.6.2\n+++ __rvm_detect_xcode_version\n+++ typeset version_file\n+++ for version_file in /Applications/Xcode.app/Contents/version.plist /Developer/Applications/Xcode.app/Contents/version.plist\n+++ [[ -f /Applications/Xcode.app/Contents/version.plist ]]\n+++ [[ -x /usr/libexec/PlistBuddy ]]\n+++ /usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' /Applications/Xcode.app/Contents/version.plist\n+++ return 0\n++ typeset __xcode_version=26.0\n++ [[ -n 26.0 ]]\n++ __rvm_version_compare 26.0 -ge 4.6.2\n++ typeset first\n+++ command printf %b '26.0\\n4.6.2\\n'\n+++ printf %b '26.0\\n4.6.2\\n'\n+++ __rvm_version_sort\n+++ command head -n1\n+++ head -n1\n+++ command awk '-F[.-]' -v OFS=. '{                   # split on \".\" and \"-\", merge back with \".\"\n    original=$0                                        # save original to preserve it before the line is changed\n    for (n=1; n\u003C10; n++) {                             # iterate through max 9 components of version\n      $n=tolower($n)                                   # ignore case for sorting\n      if ($n == \"\")                 $n=\"0\"             # treat non existing parts as 0\n      if ($n ~ /^p[0-9]/)           $n=substr($n, 2)   # old ruby -p notation\n      if ($n ~ /^[0-9](rc|b)/)      $n=substr($n, 1, 1)\". \"substr($n, 2)   # old jruby 0RC1 notation\n      if (n == 1 && $n ~ /^[0-9]/)  $n=\"zzz.\"$n        # first group must be a string\n      if (n > 1 && $n ~ /^[a-z]/)   $n=\" \"$n           # names go before numbers thanks to space\n    }\n    print $0\"\\t\"original                               # print the transformed version and original separated by \\t\n                                                       # so we can extract original after sorting\n  }'\n+++ awk '-F[.-]' -v OFS=. '{                   # split on \".\" and \"-\", merge back with \".\"\n    original=$0                                        # save original to preserve it before the line is changed\n    for (n=1; n\u003C10; n++) {                             # iterate through max 9 components of version\n      $n=tolower($n)                                   # ignore case for sorting\n      if ($n == \"\")                 $n=\"0\"             # treat non existing parts as 0\n      if ($n ~ /^p[0-9]/)           $n=substr($n, 2)   # old ruby -p notation\n      if ($n ~ /^[0-9](rc|b)/)      $n=substr($n, 1, 1)\". \"substr($n, 2)   # old jruby 0RC1 notation\n      if (n == 1 && $n ~ /^[0-9]/)  $n=\"zzz.\"$n        # first group must be a string\n      if (n > 1 && $n ~ /^[a-z]/)   $n=\" \"$n           # names go before numbers thanks to space\n    }\n    print $0\"\\t\"original                               # print the transformed version and original separated by \\t\n                                                       # so we can extract original after sorting\n  }'\n+++ LC_ALL=C\n+++ sort -t. -k 1,1d -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n\n+++ awk '-F\\t' '{print $2}'\n++ first=4.6.2\n++ case \"$2\" in\n++ [[ 4.6.2 == \\h\\e\\a\\d ]]\n++ [[ 4.6.2 == \\4\\.\\6\\.\\2 ]]\n++ return 0\n++ true\n++ brew update\nError: Running Homebrew as root is extremely dangerous and no longer supported.\nAs Homebrew does not drop privileges on installation you would be giving all\nbuild scripts full access to your system.\n++ typeset ret=1\n++ rvm_error 'Failed to update Homebrew, follow instructions at\n\n    https://docs.brew.sh/Common-Issues\n\nand make sure `brew update` works before continuing.'\n++ rvm_pretty_print stderr\n++ case \"${rvm_pretty_print_flag:=auto}\" in\n++ case \"${TERM:-dumb}\" in\n++ case \"$1\" in\n++ [[ -t 2 ]]\n++ return 1\n++ printf %b 'Failed to update Homebrew, follow instructions at\n\n    https://docs.brew.sh/Common-Issues\n\nand make sure `brew update` works before continuing.\\n'\n++ return 1\n\n```\n\nlog里面说：\n> Error: Running Homebrew as root is extremely dangerous and no longer supported.\nAs Homebrew does not drop privileges on installation you would be giving all\nbuild scripts full access to your system.\n++ typeset ret=1\n> ++ rvm_error 'Failed to update Homebrew, follow instructions at\n>\n>    https://docs.brew.sh/Common-Issues\n>\n> and make sure `brew update` works before continuing.'\n\n所以依然提到是Homebrew的问题，但我没有发现Homebrew哪里有问题，brew update也已经执行过了，brew命令也能正常执行，所以要考虑其他问题。\n\n恰巧我以前在配置电脑环境中也遇到过openssl版本的问题，所以我怀疑是不是跟openssl版本有关系，这样想的原因是印象中有要把openssl升级到1版本的需要，然后在网上查到确实也有人提出要升级openssl的解决办法，索性尝试一下。\n\n![brew install openssl](https://image.xinwei.ltd/image1758366811778.png)\n从截图中可以看出，我电脑上的openssl已经是最新的，有点奇怪。\n\n那我在执行命令时，尝试直接指定openssl的位置，试一下，结果成功了。\n\n最终解决方案（ruby最新版本是3.4.6）：\n```terminal\nrvm install ruby-3.4.6 --with-openssl-dir=$(brew --prefix openssl@1.1)\n```\n![rvm install](https://image.xinwei.ltd/image1758367026139.png)\n\n查看是否生效：\n```terminal\n➜  ~ rvm docs generate-ri\nGenerating ri documentation.....................................\n➜  ~ rvm list\n=* ruby-3.4.6 [ x86_64 ]\n\n# => - current\n# =* - current && default\n#  * - default\n➜  ~ \n```\n\n这样就可以了。\n\n\n\n\n\n\n","最近换了电脑，所以又需要配置一下电脑的环境，但是在遇到ruby环境的升级时又遇到了新的问题，所以在此记录一下。","https://image.xinwei.ltd/image1758365862537.png",499668042977349,{"phone":15,"userId":13,"nickName":16,"vipType":17,"avatar":18,"sign":19,"createdAt":20},"13121171998","全栈老韩",1,"https://image.xinwei.ltd/images/IMG_5430.JPG","全栈工程师，擅长iOS App开发、前端（vue、react、nuxt、小程序&Taro）开发、Flutter、React Native、后端（midwayjs、golang、express、koa）开发、docker容器、seo优化等。","2024-01-01T16:14:30.305Z",2,{"id":21,"name":23},"IT技术",18,{"id":24,"name":26,"parentId":21},"Linux",[],"",74,0,"rvm update,ruby install,install ruby,ruby update,ruby,rvm"]