{"id":220,"date":"2025-11-25T16:22:05","date_gmt":"2025-11-25T08:22:05","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=220"},"modified":"2025-11-25T16:22:05","modified_gmt":"2025-11-25T08:22:05","slug":"mac-%e5%8d%87%e7%ba%a7-ruby-%e5%88%b0-3-2-0-%e6%88%96%e6%9b%b4%e9%ab%98%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/11\/25\/mac-%e5%8d%87%e7%ba%a7-ruby-%e5%88%b0-3-2-0-%e6%88%96%e6%9b%b4%e9%ab%98%e7%89%88%e6%9c%ac\/","title":{"rendered":"MAC \u5347\u7ea7 Ruby \u5230 3.2.0 \u6216\u66f4\u9ad8\u7248\u672c"},"content":{"rendered":"\n<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4efd <strong>\u5728 macOS \u4e0a\u5c06 Ruby \u5347\u7ea7\u5230 3.2.0 \u6216\u66f4\u9ad8\u7248\u672c<\/strong> \u7684\u6700\u63a8\u8350\u3001\u6700\u5e72\u51c0\u3001\u6700\u7a33\u5b9a\u7684\u65b9\u6848\uff08\u517c\u5bb9 Intel \/ M1 \/ M2 \/ M3 \u8bbe\u5907\uff09\u3002<br><strong>\u4e0d\u4fee\u6539\u7cfb\u7edf\u81ea\u5e26 Ruby\uff0c\u53ea\u989d\u5916\u5b89\u88c5\u65b0\u7248 Ruby<\/strong> \u2014\u2014\u8fd9\u662f Apple \u5b98\u65b9\u5efa\u8bae\u7684\u505a\u6cd5\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u2705 \u6700\u63a8\u8350\u65b9\u5f0f\uff1a\u4f7f\u7528 Homebrew \u5b89\u88c5 Ruby\uff08\u7b80\u5355\u3001\u7a33\u5b9a\u3001\u65e0\u51b2\u7a81\uff09<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">1\ufe0f\u20e3 \u5b89\u88c5 Homebrew\uff08\u5982\u5df2\u5b89\u88c5\u53ef\u8df3\u8fc7\uff09<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">2\ufe0f\u20e3 \u5b89\u88c5 Ruby 3.2 \u6216\u66f4\u9ad8\u7248\u672c<\/h1>\n\n\n\n<p>Homebrew \u4e00\u822c\u63d0\u4f9b Ruby \u6700\u65b0\u7248\u672c\uff08\u5982 3.3.x\uff09<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nbrew install ruby\n\n<\/pre><\/div>\n\n\n<p>\u4f60\u4e5f\u53ef\u4ee5\u6307\u5b9a\u7248\u672c\uff08\u4f46 Homebrew \u901a\u5e38\u4e0d\u518d\u63d0\u4f9b\u65e7\u7248\u672c\uff09\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">3\ufe0f\u20e3 \u914d\u7f6e PATH\uff08\u5173\u952e\u6b65\u9aa4\uff0c\u5426\u5219 Ruby \u4ecd\u662f\u7cfb\u7edf\u7248\u672c\uff09<\/h1>\n\n\n\n<p>\u6839\u636e CPU \u7ed3\u6784\u4e0d\u540c\uff0c\u8def\u5f84\u4e0d\u540c\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udf4f Apple Silicon (M1\/M2\/M3)<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\necho &#039;export PATH=&quot;\/opt\/homebrew\/opt\/ruby\/bin:$PATH&quot;&#039; &gt;&gt; ~\/.zshrc\necho &#039;export LDFLAGS=&quot;-L\/opt\/homebrew\/opt\/ruby\/lib&quot;&#039; &gt;&gt; ~\/.zshrc\necho &#039;export CPPFLAGS=&quot;-I\/opt\/homebrew\/opt\/ruby\/include&quot;&#039; &gt;&gt; ~\/.zshrc\nsource ~\/.zshrc\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udcbb Intel Mac<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\necho &#039;export PATH=&quot;\/usr\/local\/opt\/ruby\/bin:$PATH&quot;&#039; &gt;&gt; ~\/.zshrc\necho &#039;export LDFLAGS=&quot;-L\/usr\/local\/opt\/ruby\/lib&quot;&#039; &gt;&gt; ~\/.zshrc\necho &#039;export CPPFLAGS=&quot;-I\/usr\/local\/opt\/ruby\/include&quot;&#039; &gt;&gt; ~\/.zshrc\nsource ~\/.zshrc\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">4\ufe0f\u20e3 \u786e\u8ba4 Ruby \u662f\u5426\u6210\u529f\u5347\u7ea7<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nruby -v\n\n<\/pre><\/div>\n\n\n<p>\u4f60\u5e94\u8be5\u770b\u5230\u7c7b\u4f3c\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nruby 3.3.0 (2024-01) &#x5B;arm64-darwin]\n\n<\/pre><\/div>\n\n\n<p>\u82e5\u4ecd\u663e\u793a 2.x \u2192 PATH \u914d\u7f6e\u4e0d\u6b63\u786e\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">5\ufe0f\u20e3\uff08\u53ef\u9009\uff09\u5207\u6362 gem \u6e90\u4e3a\u66f4\u5feb\u7684\u955c\u50cf<\/h1>\n\n\n\n<p>\u5982\u679c\u4f60\u8981\u88c5 CocoaPods\uff0c\u8fd9\u4e00\u6b65\u5efa\u8bae\u505a\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngem sources --add https:\/\/gems.ruby-china.com\/ --remove https:\/\/rubygems.org\/\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">6\ufe0f\u20e3 \uff08\u53ef\u9009\uff09\u5347\u7ea7 gem\u3001\u5b89\u88c5 cocoapods<\/h1>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngem update --system\ngem install cocoapods\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\ude80 \u65b9\u6848 B\uff1a\u7528 rbenv \u5b89\u88c5 Ruby\uff08\u9002\u5408\u9700\u8981\u591a\u4e2a\u7248\u672c\u7684\u5f00\u53d1\u8005\uff09<\/h1>\n\n\n\n<p>\u5982\u679c\u9700\u8981\u7ba1\u7406\u591a\u4e2a Ruby \u7248\u672c\uff0c\u5efa\u8bae\u4f7f\u7528\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nbrew install rbenv ruby-build\n\n<\/pre><\/div>\n\n\n<p>\u5b89\u88c5 Ruby 3.2\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nrbenv install 3.2.0\nrbenv global 3.2.0\n\n<\/pre><\/div>\n\n\n<p>\u67e5\u770b\u7248\u672c\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nruby -v\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u26a0\ufe0f \u6ce8\u610f\uff1a\u4e0d\u8981\u5c1d\u8bd5\u201c\u5347\u7ea7\u7cfb\u7edf\u81ea\u5e26 Ruby\u201d<\/h1>\n\n\n\n<p>macOS \u7684\u7cfb\u7edf Ruby \u4f4d\u4e8e\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/usr\/bin\/ruby\n\n<\/pre><\/div>\n\n\n<p>\u8fd9\u662f\u53d7\u4fdd\u62a4\u6587\u4ef6\uff08SIP\uff09\uff0c\u4e0d\u53ef\u5347\u7ea7\u3001\u4e0d\u53ef\u5220\u9664\u3001\u4e0d\u53ef\u4fee\u6539\uff0c\u4efb\u4f55\u5c1d\u8bd5\u66ff\u6362\u90fd\u4f1a\u5bfc\u81f4\u7cfb\u7edf\u95ee\u9898\u3002<\/p>\n\n\n\n<p><strong>\u6b63\u786e\u505a\u6cd5 \u2192 \u5b89\u88c5\u65b0\u7248 Ruby\uff0c\u8ba9 PATH \u4f18\u5148\u4f7f\u7528\u5b83\u3002<\/strong><\/p>\n\n\n\n<p>\u597d\u7684\u963f\u6770\uff01\u4f60\u8bf4\u201c\u5e0c\u671b\u201d\uff0c\u6211\u7406\u89e3\u4e3a <strong>\u4f60\u5e0c\u671b\u6211\u5e2e\u4f60\u751f\u6210\u4e00\u6761\u201c\u4e00\u952e\u5b89\u88c5 Ruby 3.2+ \u7684\u81ea\u52a8\u811a\u672c\u201d<\/strong>\u3002<br>\u6211\u73b0\u5728\u76f4\u63a5\u7ed9\u4f60 <strong>\u4e00\u952e\u811a\u672c + \u4f7f\u7528\u8bf4\u660e<\/strong>\uff0c\u590d\u5236\u5230\u7ec8\u7aef\u6267\u884c\u5373\u53ef\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\ude80 Mac \u4e00\u952e\u5347\u7ea7 Ruby \u5230 3.2+ \u7684\u81ea\u52a8\u811a\u672c\uff08\u9002\u914d M1 \/ M2 \/ M3 \/ Intel\uff09<\/h1>\n\n\n\n<p>\u4e0b\u9762\u811a\u672c\u4f1a\u81ea\u52a8\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u68c0\u6d4b Homebrew<\/li>\n\n\n\n<li>\u81ea\u52a8\u5b89\u88c5 Ruby\uff08\u6700\u65b0\u7248\u672c \u22653.2\uff09<\/li>\n\n\n\n<li>\u81ea\u52a8\u6dfb\u52a0 PATH<\/li>\n\n\n\n<li>\u81ea\u52a8\u5207\u6362 gem \u6e90<\/li>\n\n\n\n<li>\u81ea\u52a8\u9a8c\u8bc1 Ruby \u7248\u672c<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udce6 <strong>\u4e00\u952e\u5b89\u88c5\u811a\u672c<\/strong><\/h1>\n\n\n\n<p>\u628a\u4e0b\u9762\u6574\u6bb5\u590d\u5236\u5230\u7ec8\u7aef\u6267\u884c\u5373\u53ef\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n#!\/bin\/bash\n\necho &quot;\ud83c\udf4e \u5f00\u59cb\u5347\u7ea7 Ruby \u5230 3.2+ ...&quot;\n\n# \u68c0\u67e5\u662f\u5426\u5b89\u88c5 Homebrew\nif ! command -v brew &amp;amp;&gt;\/dev\/null; then\n  echo &quot;\ud83d\udce6 \u672a\u68c0\u6d4b\u5230 Homebrew\uff0c\u5f00\u59cb\u5b89\u88c5...&quot;\n  \/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;\nelse\n  echo &quot;\u2714 \u5df2\u68c0\u6d4b\u5230 Homebrew&quot;\nfi\n\necho &quot;\ud83d\udd27 \u66f4\u65b0 Homebrew...&quot;\nbrew update\n\n# \u5b89\u88c5 ruby\necho &quot;\ud83d\udce5 \u6b63\u5728\u5b89\u88c5 Ruby\uff083.2+ \u6216\u6700\u65b0\u7248\u672c\uff09...&quot;\nbrew install ruby\n\n# \u5224\u65ad\u82af\u7247\u67b6\u6784\nARCH=$(uname -m)\nif &#x5B; &quot;$ARCH&quot; = &quot;arm64&quot; ]; then\n  RUBY_PATH=&quot;\/opt\/homebrew\/opt\/ruby\/bin&quot;\n  RUBY_LIB=&quot;\/opt\/homebrew\/opt\/ruby\/lib&quot;\n  RUBY_INC=&quot;\/opt\/homebrew\/opt\/ruby\/include&quot;\nelse\n  RUBY_PATH=&quot;\/usr\/local\/opt\/ruby\/bin&quot;\n  RUBY_LIB=&quot;\/usr\/local\/opt\/ruby\/lib&quot;\n  RUBY_INC=&quot;\/usr\/local\/opt\/ruby\/include&quot;\nfi\n\n# \u6dfb\u52a0 PATH\necho &quot;\ud83d\udd27 \u914d\u7f6e Ruby \u73af\u5883\u53d8\u91cf...&quot;\necho &quot;export PATH=\\&quot;$RUBY_PATH:\\$PATH\\&quot;&quot; &gt;&gt; ~\/.zshrc\necho &quot;export LDFLAGS=\\&quot;-L$RUBY_LIB\\&quot;&quot; &gt;&gt; ~\/.zshrc\necho &quot;export CPPFLAGS=\\&quot;-I$RUBY_INC\\&quot;&quot; &gt;&gt; ~\/.zshrc\n\nsource ~\/.zshrc\n\necho &quot;\ud83c\udf10 \u5207\u6362 gem \u6e90\u5230 Ruby China\uff0c\u52a0\u901f\u5b89\u88c5...&quot;\ngem sources --add https:\/\/gems.ruby-china.com\/ --remove https:\/\/rubygems.org\/\n\necho &quot;\u2728 \u5347\u7ea7 RubyGems...&quot;\ngem update --system\n\necho &quot;\ud83d\udd0d \u68c0\u6d4b Ruby \u7248\u672c...&quot;\nruby -v\n\necho &quot;&quot;\necho &quot;\ud83c\udf89 Ruby \u5df2\u6210\u529f\u5347\u7ea7\uff01\u4f60\u73b0\u5728\u4f7f\u7528\u7684\u662f\uff1a&quot;\nruby -v\n\necho &quot;\ud83d\udccc \u4f60\u5df2\u7ecf\u53ef\u4ee5\u7ee7\u7eed\u5b89\u88c5 CocoaPods\uff08\u5982\u9700\u8981\uff09\uff1a&quot;\necho &quot;    gem install cocoapods&quot;\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\uddea \u4f7f\u7528\u65b9\u6cd5<\/h1>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6253\u5f00 <strong>\u7ec8\u7aef Terminal<\/strong><\/li>\n\n\n\n<li>\u7c98\u8d34\u811a\u672c<\/li>\n\n\n\n<li>\u56de\u8f66\u6267\u884c<\/li>\n\n\n\n<li>\u5b8c\u6210\u540e\u8f93\u5165\uff1a<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nruby -v\n\n<\/pre><\/div>\n\n\n<p>\u5e94\u8be5\u770b\u5230\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nruby 3.2.x \u6216 ruby 3.3.x\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4efd \u5728 macOS \u4e0a\u5c06 Ruby \u5347\u7ea7\u5230 3.2.0 \u6216\u66f4\u9ad8\u7248\u672c \u7684&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/11\/25\/mac-%e5%8d%87%e7%ba%a7-ruby-%e5%88%b0-3-2-0-%e6%88%96%e6%9b%b4%e9%ab%98%e7%89%88%e6%9c%ac\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-220","post","type-post","status-publish","format-standard","hentry","category-ruby"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":221,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/220\/revisions\/221"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}