当前位置: 首页 > 工具软件 > Topaz Ruby > 使用案例 >

MAC Ruby 安装

羊城
2023-12-01

首先需要在 Mac 中安装 Ruby 环境

  • 先安装好 RVM

  • rvm是一个便捷的多版本ruby环境的管理和切换工具 官网:https://rvm.io/

  • 在终端控制台命令:
    $ curl -sSL https://get.rvm.io | bash -s stable 之后按回车键

  • 如下所示:


:~ admin$ curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.1.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.1/1.29.1.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.1/1.29.1.tar.gz.asc',
but no GPG software exists to validate it, skipping.

Installing RVM to /Users/admin/.rvm/
    Adding rvm PATH line to /Users/admin/.profile /Users/admin/.mkshrc /Users/admin/.bashrc /Users/admin/.zshrc.
    Adding rvm loading line to /Users/admin/.profile /Users/admin/.bash_profile /Users/admin/.zlogin.
Installation of RVM in /Users/admin/.rvm/ is almost complete:

  * To start using RVM you need to run `source /Users/admin/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

# admin,
#
#   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
  • 等待一段时间后!就可以成功安装好 RVM。
1.2 然后,载入 RVM 环境:
$ source ~/.rvm/scripts/rvm
1.3 修改 RVM 下载 Ruby 的源,到 Ruby China 的镜像:
echo "ruby_url=https://cache.ruby-china.org/pub/ruby" > ~/.rvm/user/db
1.3.1 检查一下是否安装正确
$ rvm -v

//如下所示:
AdmindeiMac-4:~ admin$ source ~/.rvm/scripts/rvm
AdmindeiMac-4:~ admin$ echo "ruby_url=https://cache.ruby-china.org/pub/ruby" > ~/.rvm/user/db
AdmindeiMac-4:~ admin$ rvm -v
rvm 1.29.1 (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.2 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]


第二步:安装ruby

列出ruby可安装的版本信息 (20170719版本最新的是2.4.0)
$ rvm list known
安装一个ruby版本
$ rvm install 2.4.0
如果想设置为默认版本,可以用这条命令来完成
$ rvm use 2.4.0 --default

如下所示:

AdmindeiMac-4:~ admin$ 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[.6]
[ruby-]2.3[.3]
[ruby-]2.4[.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[.26]
jruby[-9.1.7.0]
jruby-head

# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx-2[.5.8]
rbx[-3.71]
rbx-head

# Opal
opal

# Minimalistic ruby implementation - ISO 30170:2012
mruby-1.0.0
mruby-1.1.0
mruby-1[.2.0]
mruby[-head]

# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]

# Topaz
topaz

# MagLev
maglev[-head]
maglev-1.0.0

# 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

:~ admin$ rvm install 2.4 --default
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.12/x86_64/ruby-2.4.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: libyaml, readline, libksba, openssl@1.1......
Certificates in '/usr/local/etc/openssl@1.1/cert.pem' are already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/admin/.rvm/rubies/ruby-2.4.0, this may take a while depending on your cpu(s)...
ruby-2.4.0 - #downloading ruby-2.4.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
100 11.9M  100 11.9M    0     0  7226k      0  0:00:01  0:00:01 --:--:-- 7222k
ruby-2.4.0 - #extracting ruby-2.4.0 to /Users/admin/.rvm/src/ruby-2.4.0....
ruby-2.4.0 - #configuring......................................................-
ruby-2.4.0 - #post-configuration.
ruby-2.4.0 - #compiling........................................................|
ruby-2.4.0 - #installing.......
ruby-2.4.0 - #making binaries executable..
ruby-2.4.0 - #downloading rubygems-2.6.10
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  747k  100  747k    0     0   395k      0  0:00:01  0:00:01 --:--:--  395k
ruby-2.4.0 - #extracting rubygems-2.6.10....
ruby-2.4.0 - #removing old rubygems.........
ruby-2.4.0 - #installing rubygems-2.6.10.....................
ruby-2.4.0 - #gemset created /Users/admin/.rvm/gems/ruby-2.4.0@global
ruby-2.4.0 - #importing gemset /Users/admin/.rvm/gemsets/global.gems...........|
ruby-2.4.0 - #generating global wrappers........
ruby-2.4.0 - #gemset created /Users/admin/.rvm/gems/ruby-2.4.0
ruby-2.4.0 - #importing gemsetfile /Users/admin/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.4.0 - #generating default wrappers........
ruby-2.4.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.4.0 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri
AdmindeiMac-4:~ admin$ ruby -v 
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]


下面的不用看是我在其他电脑上安装的 20170717 —— rvm_ 1.29.2版本
Last login: Mon Jul 17 16:33:49 on ttys001
-bash: /Users/admin: is a directory
********:~ admin$ curl -sSL https://get.rvm.io | bash -s stable
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/admin/.rvm/
    RVM PATH line found in /Users/admin/.mkshrc /Users/admin/.profile /Users/admin/.bashrc /Users/admin/.zshrc.
    RVM sourcing line found in /Users/admin/.profile /Users/admin/.bash_profile /Users/admin/.zlogin.
Upgrade of RVM in /Users/admin/.rvm/ is complete.

# *****,
#
#   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.

********:~ admin$ 

20180425 更新Ruby: —— rvm_ 1.29.3版本 —— Ruby_ 2.4.1版本

~ admin$  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.3.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
curl: (28) Connection timed out after 30000 milliseconds

Could not download 'https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc'.
  curl returned status '28'.


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

Upgrade Notes:

  * No new notes to display.

RVM reloaded!

-------------------------------------------------------------------------

:~ admin$ rvm -v
rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

-------------------------------------------------------------------------
:~ admin$ 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[.7]
[ruby-]2.3[.4]
[ruby-]2.4[.1]  ---------------Ruby最新的版本----------------------------------------------------------
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.13.0]
jruby-head

# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx-2[.5.8]
rbx-3[.84]
rbx-head

# 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[-head]

# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]

# Topaz
topaz

# MagLev
maglev[-head]
maglev-1.0.0

# 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

-----------------------------------------------------------------------

:~ admin$ rvm install "ruby-2.4.1"
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.13/x86_64/ruby-2.4.1.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core, homebrew/versions).
==> New Formulae
abyss                                    lgogdownloader
...
libmonome
==> Renamed Formulae
arm -> nyx                               newsbeuter -> newsboat
...
mobile-shell -> mosh                     transfig -> fig2dev
==> Deleted Formulae
gmp@4 ✔                                  ledger@2.6
...
kubernetes-cli@1.3

==> Upgrading 5 outdated packages, with result:
automake 1.15 -> 1.16.1, coreutils 8.26 -> 8.29, openssl@1.1 1.1.0e -> 1.1.0h, pkg-config 0.29.1_2 -> 0.29.2, readline 7.0.3 -> 7.0.3_1
==> Upgrading openssl@1.1 
==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.0h.high_sie
######################################################################## 100.0%
==> Pouring openssl@1.1-1.1.0h.high_sierra.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl@1.1/lib
    CPPFLAGS: -I/usr/local/opt/openssl@1.1/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/openssl@1.1/lib/pkgconfig

==> Summary
 类似资料: