1 Mac Ruby 安裝教程

更新并測試于 20240222

在 Mac 中安裝 Ruby 痴颊、需要先安裝好 RVM
  • RVM 是一個便捷的 多版本 Ruby 環(huán)境的 管理 和 切換 工具
  • 官網(wǎng):https://rvm.io/
  • 截止到目前 最新版本是 rvm 1.29.12
在終端控制臺 輸入命令行 :
$ curl -sSL https://get.rvm.io | bash -s stable  

如果 報錯 : 
curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 16 ms: Connection refused

通過 https://ip.tool.chinaz.com/raw.githubusercontent.com
raw.githubusercontent.com  得到 ip 
然后 修改 電腦的 iHosts  文件 

Mac ~ % curl -sSL https://get.rvm.io | bash -s stable  
Downloading https://github.com/rvm/rvm/archive/1.29.10.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.10/1.29.10.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.10/1.29.10.tar.gz.asc',
but no GPG software exists to validate it, skipping.
Upgrading the RVM installation in /Users/shiran/.rvm/
    RVM PATH line found in /Users/shiran/.mkshrc /Users/shiran/.profile /Users/shiran/.bashrc /Users/shiran/.zshrc.
    RVM sourcing line found in /Users/shiran/.profile /Users/shiran/.bash_profile /Users/shiran/.zlogin.
Upgrade of RVM in /Users/shiran/.rvm/ is complete.

Thanks for installing RVM ??
Please consider donating to our open collective to help us maintain RVM.

??  Donate: https://opencollective.com/rvm/donate

Mac ~ % rvm -v
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

===============================================

1.2 然后 載入 RVM 環(huán)境 
    $ source ~/.rvm/scripts/rvm

1.3 修改 RVM 下載 Ruby 的源 到 Ruby China 的鏡像  喂很! 
    記住這個鏡像 是 ruby-china.com 不是其他的  
    $ echo "ruby_url=https://cache.ruby-china.com/pub/ruby" > ~/.rvm/user/db

1.3.1 檢查一下是否安裝正確
    $ rvm -v

如下所示 :
Mac :~ admin $ source ~/.rvm/scripts/rvm
Mac :~ admin $ echo "ruby_url=https://cache.ruby-china.com/pub/ruby" > ~/.rvm/user/db
Mac :~ admin $ rvm -v
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]
如果能顯示版本號,則安裝成功。

更新 RVM : rvm get stable 如下所示 :

Mac:~ mac$ rvm get stable
Downloading https://get.rvm.io
No GPG software exists to validate rvm-installer, skipping.
Downloading https://github.com/rvm/rvm/archive/1.29.2.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.2/1.29.2.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.2/1.29.2.tar.gz.asc',
but no GPG software exists to validate it, skipping.

Upgrading the RVM installation in /Users/mac/.rvm/
    RVM PATH line found in /Users/mac/.mkshrc /Users/mac/.profile /Users/mac/.bashrc /Users/mac/.zshrc.
    RVM sourcing line found in /Users/mac/.profile /Users/mac/.bash_profile /Users/mac/.zlogin.
Upgrade of RVM in /Users/mac/.rvm/ is complete.

# xinxin,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.

In case of problems: https://rvm.io/help and https://twitter.com/rvm_io

Upgrade Notes:

  * No new notes to display.

RVM reloaded!

-------------------------------------------------------------------------
Mac:~ mac$ rvm -v
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]
第二步:安裝 Ruby ( 無法顯示最新版本的 Ruby )

列出 Ruby 可安裝的版本信息
$ rvm list known
安裝一個 Ruby 版本
$ rvm install 3.0 --default


先查詢版本 : $ rvm list known
shiran$ rvm list known
# 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[.10]
[ruby-]2.5[.8]
[ruby-]2.6[.6]
[ruby-]2.7[.2]
[ruby-]3[.0.0]
ruby-head

# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.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 3.0 --default


如果中間停頓,則是 要授權(quán) 輸入 yes 即可辟癌,
初次安裝要等好久背苦,切記要耐心 !

報錯 :
Requirements installation failed with status: 56.

這種情況先升級 rvm 就可以了,
升級 rvm 命令 :rvm get master 
然后再升級 ruby :rvm install 3.0 --default


mac : $ rvm install 3.0 --default
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/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.
About to install Homebrew in the default location `/usr/local`.

It is possible to select a custom location, however it is not recommended and some things might not work.
You should do it only if you do not have write rights to `/usr/local`.

Press ENTER to install Homebrew in the default location `/usr/local`
or type a custom path (needs to be writable for the current user)
: yes
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   128    0   128    0     0    200      0 --:--:-- --:--:-- --:--:--   200
100 1733k  100 1733k    0     0  27493      0  0:01:04  0:01:04 --:--:-- 49124
Installing requirements for osx.
Updating system........................
Installing required packages: autoconf, automake, libtool, pkg-config, coreutils, libyaml, libksba, readline, zlib, openssl@1.1...................
Certificates bundle '/Users/shiran/yes/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/shiran/.rvm/rubies/ruby-2.6.3, this may take a while depending on your cpu(s)...
ruby-2.6.3 - #downloading ruby-2.6.3, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (35) error:14004410:SSL routines:CONNECT_CR_SRVR_HELLO:sslv3 alert handshake failure
There was an error(35).
Checking fallback: https://ftp.ruby-lang.org/pub/ruby/2.6/ruby-2.6.3.tar.bz2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.8M  100 13.8M    0     0  1310k      0  0:00:10  0:00:10 --:--:--  795k
ruby-2.6.3 - #extracting ruby-2.6.3 to /Users/shiran/.rvm/src/ruby-2.6.3.....
ruby-2.6.3 - #configuring.......................................................................
ruby-2.6.3 - #post-configuration.
ruby-2.6.3 - #compiling......................................................................
ruby-2.6.3 - #installing...........
ruby-2.6.3 - #making binaries executable..
ruby-2.6.3 - #downloading rubygems-3.0.4
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  862k  100  862k    0     0  1487k      0 --:--:-- --:--:-- --:--:-- 1485k
ruby-2.6.3 - #extracting rubygems-3.0.4.....
ruby-2.6.3 - #removing old rubygems........
ruby-2.6.3 - #installing rubygems-3.0.4.........................................
ruby-2.6.3 - #gemset created /Users/shiran/.rvm/gems/ruby-2.6.3@global
ruby-2.6.3 - #importing gemset /Users/shiran/.rvm/gemsets/global.gems................................................................
ruby-2.6.3 - #generating global wrappers.......
ruby-2.6.3 - #gemset created /Users/shiran/.rvm/gems/ruby-2.6.3
ruby-2.6.3 - #importing gemsetfile /Users/shiran/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.3 - #generating default wrappers.......
ruby-2.6.3 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.3 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri

檢測一下:

MacBook-Pro ~ % ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]

Mac ~ % ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
Mac ~ % rvm install 3.0 --default
Already installed ruby-3.0.0.
To reinstall use:

    rvm reinstall ruby-3.0.0

Mac ~ % rvm reinstall ruby-3.0.0
ruby-3.0.0 - #removing src/ruby-3.0.0 - please wait
ruby-3.0.0 - #removing rubies/ruby-3.0.0 - please wait
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-3.0.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/mac/.rvm/rubies/ruby-3.0.0, this may take a while depending on your cpu(s)...
ruby-3.0.0 - #downloading ruby-3.0.0, this may take a while depending on your connection...
ruby-3.0.0 - #extracting ruby-3.0.0 to /Users/mac/.rvm/src/ruby-3.0.0 - please wait
ruby-3.0.0 - #configuring - please wait
ruby-3.0.0 - #post-configuration - please wait
ruby-3.0.0 - #compiling - please wait
ruby-3.0.0 - #installing - please wait
ruby-3.0.0 - #making binaries executable - please wait
Installed rubygems 3.2.3 is newer than 3.0.9 provided with installed ruby, skipping installation, use --force to force installation.
ruby-3.0.0 - #gemset created /Users/mac/.rvm/gems/ruby-3.0.0@global
ruby-3.0.0 - #importing gemset /Users/mac/.rvm/gemsets/global.gems - please wait
ruby-3.0.0 - #generating global wrappers - please wait
ruby-3.0.0 - #gemset created /Users/mac/.rvm/gems/ruby-3.0.0
ruby-3.0.0 - #importing gemsetfile /Users/mac/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-3.0.0 - #generating default wrappers - please wait
ruby-3.0.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-3.0.0 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri
Making gemset ruby-3.0.0 pristine - please wait
Making gemset ruby-3.0.0@global pristine - please wait

Mac ~ % ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末遗契,一起剝皮案震驚了整個濱河市辐棒,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌牍蜂,老刑警劉巖漾根,帶你破解...
    沈念sama閱讀 216,496評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異鲫竞,居然都是意外死亡辐怕,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,407評論 3 392
  • 文/潘曉璐 我一進(jìn)店門从绘,熙熙樓的掌柜王于貴愁眉苦臉地迎上來寄疏,“玉大人,你說我怎么就攤上這事顶考×藁梗” “怎么了?”我有些...
    開封第一講書人閱讀 162,632評論 0 353
  • 文/不壞的土叔 我叫張陵驹沿,是天一觀的道長艘策。 經(jīng)常有香客問我,道長渊季,這世上最難降的妖魔是什么朋蔫? 我笑而不...
    開封第一講書人閱讀 58,180評論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮却汉,結(jié)果婚禮上驯妄,老公的妹妹穿的比我還像新娘。我一直安慰自己合砂,他們只是感情好青扔,可當(dāng)我...
    茶點故事閱讀 67,198評論 6 388
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般微猖。 火紅的嫁衣襯著肌膚如雪谈息。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,165評論 1 299
  • 那天凛剥,我揣著相機與錄音侠仇,去河邊找鬼。 笑死犁珠,一個胖子當(dāng)著我的面吹牛逻炊,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播犁享,決...
    沈念sama閱讀 40,052評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼余素,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了炊昆?” 一聲冷哼從身側(cè)響起溺森,我...
    開封第一講書人閱讀 38,910評論 0 274
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎窑眯,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體医窿,經(jīng)...
    沈念sama閱讀 45,324評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡磅甩,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,542評論 2 332
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了姥卢。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片卷要。...
    茶點故事閱讀 39,711評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖独榴,靈堂內(nèi)的尸體忽然破棺而出僧叉,到底是詐尸還是另有隱情,我是刑警寧澤棺榔,帶...
    沈念sama閱讀 35,424評論 5 343
  • 正文 年R本政府宣布瓶堕,位于F島的核電站,受9級特大地震影響症歇,放射性物質(zhì)發(fā)生泄漏郎笆。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,017評論 3 326
  • 文/蒙蒙 一忘晤、第九天 我趴在偏房一處隱蔽的房頂上張望宛蚓。 院中可真熱鬧,春花似錦设塔、人聲如沸凄吏。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,668評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽痕钢。三九已至图柏,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間盖喷,已是汗流浹背爆办。 一陣腳步聲響...
    開封第一講書人閱讀 32,823評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留课梳,地道東北人距辆。 一個月前我還...
    沈念sama閱讀 47,722評論 2 368
  • 正文 我出身青樓,卻偏偏與公主長得像暮刃,于是被迫代替她去往敵國和親跨算。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,611評論 2 353

推薦閱讀更多精彩內(nèi)容