Mac系统下ruby更新和配置

文本记录于20200825

ruby安装的前提是要有rvm,rvm安装更新操作详见《Mac系统更新RVM到最新版本》

  • 更新前记录:

系统版本:macOS Catalina(10.15.5)
ruby版本:2.6.3p62

$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]

但是查询已经安装的ruby时显示并没有安装:

$ rvm list

# No rvm rubies installed yet. Try 'rvm help install'.

那么想要把当前版本设为默认版本,执行命令也是不行:

$ rvm use 2.6.3 --default
Required ruby-2.6.3 is not installed.
To install do: 'rvm install "ruby-2.6.3"'
$ rvm use 2.6.3p62 --default
Required ruby-2.6.3p62 is not installed.
To install do: 'rvm install "ruby-2.6.3p62"'

两个都不行,我也不懂,反正不行。 那就全部更新下到最新版本再说吧。

  • 版本更新操作记录:
1.列出 Ruby 可安装的版本信息
$ rvm list known 
2.安装一个 Ruby 版本
$ rvm install 2.7.0
3.如果想设置为默认版本,可以用这条命令来完成
$ rvm use 2.7.0 --default

按步骤查看当前rvm可安装的ruby版本如下:

$ 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[.9]
[ruby-]2.5[.7]
[ruby-]2.6[.5]
[ruby-]2.7[.0]
ruby-head

# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2

.
.
.

# IronRuby
ironruby[-1.1.3]
ironruby-head

查看到最新版本ruby版本是2.7,那就装这个吧(时间贼久,装了将近1个钟头 中间还发生失败过一次,执行原命令继续下载):

$ rvm install 2.7 --default
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.7.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system...........
Installing required packages: coreutils, libyaml, libksba, readline, zlib, openssl@1.1..............
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/XXX/.rvm/rubies/ruby-2.7.0, this may take a while depending on your cpu(s)...
ruby-2.7.0 - #downloading ruby-2.7.0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 98 14.0M   98 13.7M    0     0   8007      0  0:30:36  0:30:00  0:00:36 16102
Warning: Transient problem: timeout Will retry in 2 seconds. 3 retries left.
Throwing away 14413569 bytes
 58 14.0M   58 8366k    0     0   7310      0  0:33:31  0:19:32  0:13:59     0
curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
There was an error(56).
Checking fallback: https://ftp.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0.tar.bz2
** Resuming transfer from byte position 8567699
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 50 5991k   50 3008k    0     0   4718      0  0:21:40  0:10:52  0:10:48     0
curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
There was an error(56).
Failed download
There has been an error fetching the ruby interpreter. Halting the installation.

$ rvm install 2.7
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.7.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/XXX/.rvm/rubies/ruby-2.7.0, this may take a while depending on your cpu(s)...
ruby-2.7.0 - #downloading ruby-2.7.0, this may take a while depending on your connection...
** Resuming transfer from byte position 11648022
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:30 --:--:--     0
Warning: Transient problem: timeout Will retry in 2 seconds. 3 retries left.
100 2983k  100 2983k    0     0   5676      0  0:08:58  0:08:58 --:--:-- 11850
ruby-2.7.0 - #extracting ruby-2.7.0 to /Users/XXX/.rvm/src/ruby-2.7.0.....
ruby-2.7.0 - #configuring.........................................................................
ruby-2.7.0 - #post-configuration.
ruby-2.7.0 - #compiling.......................................................................................................|
ruby-2.7.0 - #installing............
ruby-2.7.0 - #making binaries executable...
Installed rubygems 3.1.2 is newer than 3.0.8 provided with installed ruby, skipping installation, use --force to force installation.
ruby-2.7.0 - #gemset created /Users/XXX/.rvm/gems/ruby-2.7.0@global
ruby-2.7.0 - #importing gemset /Users/XXX/.rvm/gemsets/global.gems.........................................................-
ruby-2.7.0 - #generating global wrappers.......
ruby-2.7.0 - #gemset created /Users/XXX/.rvm/gems/ruby-2.7.0
ruby-2.7.0 - #importing gemsetfile /Users/XXX/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.7.0 - #generating default wrappers.......
ruby-2.7.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.7.0 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri

更新命令执行结束, 那么来看下ruby版本和安装信息:

$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
$ rvm list
=* ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

这就算是更新成功过了。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 207,113评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,644评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 153,340评论 0 344
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,449评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,445评论 5 374
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,166评论 1 284
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,442评论 3 401
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,105评论 0 261
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,601评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,066评论 2 325
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,161评论 1 334
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,792评论 4 323
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,351评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,352评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,584评论 1 261
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,618评论 2 355
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,916评论 2 344