Skip to content

Translate installation to latest content (zh_tw) #3103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 133 additions & 33 deletions zh_tw/documentation/installation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ lang: zh_tw
有很多工具可以安裝 Ruby。本頁介紹如何使用主流的套件管理工具以及第三方工具來管理、安裝 Ruby 以及如何從原始碼來編譯 Ruby。
{: .summary}

如果您已經在您的電腦上安裝了 Ruby。您可以在 [terminal emulator][terminal] 中執行以下指令確認:

{% highlight sh %}
ruby -v
{% endhighlight %}

輸出結果應該會顯示已安裝的 Ruby 版本資訊。

## 選擇安裝方式

Expand All @@ -22,19 +29,26 @@ lang: zh_tw
* [套件管理系統](#package-management-systems)
* [Debian、Ubuntu](#apt)
* [CentOS、Fedora、RHEL](#yum)
* [Snap](#snap)
* [Gentoo](#portage)
* [Arch Linux](#pacman)
* [macOS](#homebrew)
* [Solaris、OpenIndiana](#solaris)
* [其他發行版](#other-systems)
* [FreeBSD](#freebsd)
* [OpenBSD](#openbsd)
* [OpenIndiana](#openindiana)
* [Windows Package Manager](#winget)
* [Chocolatey package manager for Windows](#chocolatey)
* [其它發行版](#other-systems)
* [安裝工具](#installers)
* [ruby-build](#ruby-build)
* [ruby-install](#ruby-install)
* [RubyInstaller](#rubyinstaller) (Windows)
* [RailsInstaller 和 Ruby 安裝包](#railsinstaller)
* [Ruby Stack](#rubystack)
* [版本管理](#managers)
* [asdf-vm](#asdf-vm)
* [chruby](#chruby)
* [rbenv](#rbenv)
* [rbenv for Windows](#rbenv-for-windows)
* [RVM](#rvm)
* [uru](#uru)
* [從原始碼編譯](#building-from-source)
Expand All @@ -47,19 +61,31 @@ lang: zh_tw

許多 Ruby 社群的成員強烈建議不要使用套件管理工具來安裝 Ruby,應該使用下面羅列的工具來取代。完整的優缺點超出了本文的範疇,最簡單的理由是,多數的套件管理工具安裝的 Ruby 版本老舊,如果想要使用最新版的 Ruby,確認你安裝了正確名稱的套件,或使用下面其他的工具吧。

本文包含以下套件管理工具說明:

* [Debian, Ubuntu](#apt)
* [CentOS, Fedora,RHEL](#yum)
* [Snap](#snap)
* [Gentoo](#portage)
* [Arch Linux](#pacman)
* [macOS](#homebrew)
* [FreeBSD](#freebsd)
* [OpenBSD](#openbsd)
* [OpenIndiana](#openindiana)
* [Windows Package manager](#winget)
* [Chocolatey package manager for Windows](#chocolatey)
* [Other Distribution](#other-systems)

### apt(Debian 或 Ubuntu)
{: #apt}

Debian GNU/Linux 和 Ubuntu 的使用者可以使用 apt。
Debian GNU/Linux 和 Ubuntu 的使用者可以使用 apt 套件管理工具
用法:

{% highlight sh %}
$ sudo apt-get install ruby
$ sudo apt-get install ruby-full
{% endhighlight %}

撰文當下 `ruby` 套件在 Debian 與 Ubuntu 平台上所提供的版本是老舊的穩定版 Ruby 2.3.1。


### yum(CentOS、Fedora 或 RHEL)
{: #yum}
Expand All @@ -73,6 +99,23 @@ $ sudo yum install ruby

安裝的版本通常是作業系統發行版發行日所打包的最新版 Ruby。

### snap (Ubuntu or other Linux distributions)
{: #snap}

Snap 是 Canonical 所開發的套件管理工具。內建於 Ubuntu,但 snap 也能在許多其他的 Linux 發行版上使用。
用法:

{% highlight sh %}
$ sudo snap install ruby --classic
{% endhighlight %}

我們為每個 Ruby 小版本提供了幾個 channel。
例如,使用以下指令切換到 Ruby 2.3:

{% highlight sh %}
$ sudo snap switch ruby --channel=2.3/stable
$ sudo snap refresh
{% endhighlight %}

### portage(Gentoo)
{: #portage}
Expand All @@ -83,7 +126,7 @@ Gentoo 使用 portage 套件管理工具。
$ sudo emerge dev-lang/ruby
{% endhighlight %}

預設會試著安裝 1.9 和 2.0,但還能安裝更多版本。要安裝特定版本,在 `make.conf` 設定 `RUBY_TARGETS`。進一步了解請參考 [Gentoo Ruby 專案網站][gentoo-ruby]。
要安裝特定版本,在 `make.conf` 設定 `RUBY_TARGETS`。進一步了解請參考 [Gentoo Ruby 專案網站][gentoo-ruby]。


### pacman (Arch Linux)
Expand All @@ -102,39 +145,81 @@ $ sudo pacman -S ruby
### Homebrew(macOS)
{: #homebrew}

OS X El Capitan、Yosemite 以及 Mavericks 內建 Ruby 2.0。
OS X Mountain Lion、Lion 以及 Snow Leopard 出廠內建 Ruby 1.8.7。
從 macOS El Capitan(10.11) 以上內建 Ruby 2.0 以上版本。

macOS 的使用者使用 [Homebrew][homebrew] 作為套件管理工具。
macOS 使用者多數使用 [Homebrew][homebrew] 作為套件管理工具。
用法:

{% highlight sh %}
$ brew install ruby
{% endhighlight %}

會安裝最新穩定版的 Ruby。
會安裝最新版的 Ruby。

### FreeBSD
{: #freebsd}

FreeBSD 提供以預編譯和從原始碼編譯的方法安裝 Ruby。
預編譯的套件可以透過 pkg 工具安裝:

{% highlight sh %}
$ pkg install ruby
{% endhighlight %}

從原始碼編譯的方法可以透過使用 [Ports Collection][freebsd-ports-collection] 來安裝 Ruby。
當您想要客製化建置設定選項時,這非常好用。

### Solaris 和 OpenIndiana 平台
{: #solaris}
更多在 FreeBSD 上使用 Ruby 與其生態系的資訊,請參考 [FreeBSD Ruby Project website][freebsd-ruby]。

[Sunfreeware][sunfreeware] 上的 Solaris 8 到 10 版有 Ruby 1.8.7 可用,同時 Blastwave 上也有 Ruby 1.8.7。Ruby 1.9.2p0 在 [Sunfreeware][sunfreeware] 也有,但版本已經過時了。
### OpenBSD
{: #openbsd}

要在 [OpenIndiana][openindiana] 安裝 Ruby,請使用:
[Image Packaging System (IPS)][opensolaris-pkg] 客戶端。
這會直接從 OpenSolaris 網路的原始碼庫安裝最新的 Ruby 1.9 以及 RubyGems:
OpenBSD 在發行版本 adJ 中有三個主要 Ruby 版本套件。以下指令可以看到可用的版本並進行安裝:

{% highlight sh %}
$ pkg install runtime/ruby-18
$ doas pkg_add ruby
{% endhighlight %}

您可以同時安裝多個主要版本,因為它們的執行檔的名稱不同 (例如:`ruby27`, `ruby26`)。

OpenBSD ports collection 的 `HEAD` 分支可能會在最新的 Ruby 版本釋出幾天後,在該平台提供,請參考 [最新 ports collections 的 lang/ruby][openbsd-current-ruby-ports]。

### Ruby on OpenIndiana
{: #openindiana}

在 [OpenIndiana][openindiana] 上安裝 Ruby,請使用 Image Packaging System (IPS) 客戶端。
這將會直接從 OpenIndiana repositories 安裝 Ruby 與 RubyGems。用法:

{% highlight sh %}
$ pkg install runtime/ruby
{% endhighlight %}

但用第三方工具來獲得最新版本 Ruby 可能比較好。

### Windows Package Manager
{: #winget}

在 Windows 上您可以使用 [Windows Package Manager CLI](https://github.com/microsoft/winget-cli) 來安裝 Ruby:

{% highlight sh %}
> winget install RubyInstallerTeam.Ruby
{% endhighlight %}

### Chocolatey package manager for Windows
{: #chocolatey}

在 Windows 上您也可以使用 [Chocolatey Package Manager](https://chocolatey.org/install) 來安裝 Ruby:

{% highlight sh %}
> choco install ruby
{% endhighlight %}

它會使用現有的 `msys2` 或是進行安裝以提供完整的 Ruby 開發環境。

### 其它發行版
{: #other-systems}

其它作業系統可以在發行版的套件庫上搜尋 Ruby,或是使用第三方工具可能會比較好
其它作業系統可以在發行版的套件庫上搜尋 Ruby,或是使用 [第三方工具](#installers) 可能會比較好


## 安裝工具
Expand Down Expand Up @@ -164,14 +249,11 @@ Windows 使用者,可以使用這個很棒的專案來幫助您安裝 Ruby:
下載、執行,即可!


### RailsInstaller 和 Ruby 安裝包
{: #railsinstaller}
### Ruby Stack
{: #rubystack}

若安裝 Ruby 是為了要開發 Ruby on Rails,則可用下列的安裝工具:

* [RailsInstaller][railsinstaller],
背後使用的是 RubyInstaller,但帶有 Rails 開發環境所需的工具。
支援 OS X 與 Windows。
* [Bitnami Ruby Stack][rubystack],
提供完整的 Rails 開發環境。
兼容 macOS、Linux、Windows、虛擬機器以及雲鏡像。
Expand All @@ -182,17 +264,26 @@ Windows 使用者,可以使用這個很棒的專案來幫助您安裝 Ruby:

許多 Rubyists 使用 Ruby 版本管理工具來管理多版本的 Ruby。版本管理工具有很多優點,但要注意 Ruby 官方並不提供技術支援。但要提的是每個工具背後的社群都非常有幫助。

### asdf-vm
{: #asdf-vm}

[asdf-vm][asdf-vm] 是一個可擴展的版本管理工具,可基於個別專案來管理多語言執行版本。您需要 [asdf-ruby][asdf-ruby] 插件 (使用 [ruby-build][ruby-build]) 來安裝 Ruby。


### chruby
{: #chruby}

[chruby][chruby] 可以切換 Ruby 版本。chruby 可以管理由 [ruby-install](#ruby-install) 所安裝的 Ruby,或是從原始碼所編譯的 Ruby。

[chruby][chruby] 可以在系統上管理多個版本的 Ruby。chruby 本身無法安裝 Ruby 但可以透過插件像是 [ruby-install][ruby-install] 或 [ruby-build][ruby-build] 安裝 Ruby。支援 macOS、Linux 和其他類 UNIX 的作業系統。

### rbenv
{: #rbenv}

[rbenv][rbenv] 可以在系統上安裝多個版本的 Ruby。rbenv 本身不能安裝 Ruby,但有一個流行的插件,叫做 ruby-build,可以用來安裝 Ruby。支援 macOS、Linux 和其它類 Unix 的作業系統。
[rbenv][rbenv] 可以在系統上管理多個版本的 Ruby。rbenv 本身不能安裝 Ruby,但可以使用插件 [ruby-build][ruby-build] 安裝 Ruby。支援 macOS、Linux 和其它類 Unix 的作業系統。

### rbenv for Windows
{: #rbenv-for-windows}

[rbenv for Windows][rbenv-for-windows] 可以在 Windows 作業系統上安裝多個版本的 Ruby。它是用 PowerShell 撰寫並提供 Windows 使用者原生方法來使用 Ruby。使用方式相容於在類 Unix 的作業系統上的 [rbenv][rbenv]。


### RVM ("Ruby Version Manager")
Expand Down Expand Up @@ -221,20 +312,29 @@ $ sudo make install

預設會安裝 Ruby 到 `/usr/local` 目錄。要更改安裝目錄請在使用 `./configure` 腳本時傳入 `--prefix=DIR` 選項。

您可以在 [Building Ruby instructions][building-ruby] 找到更多關於從原始碼編譯的資訊。

使用第三方工具或套件管理工具來安裝可能比較好,因為從原始碼編譯安裝的 Ruby 無法用任何工具管理。


[rvm]: http://rvm.io/
[rbenv]: https://github.com/rbenv/rbenv#readme
[rbenv]: https://github.com/rbenv/rbenv
[rbenv-for-windows]: https://github.com/ccmywish/rbenv-for-windows#readme
[ruby-build]: https://github.com/rbenv/ruby-build#readme
[ruby-install]: https://github.com/postmodern/ruby-install#readme
[chruby]: https://github.com/postmodern/chruby#readme
[uru]: https://bitbucket.org/jonforums/uru
[chruby]: https://github.com/postmodern/chruby
[uru]: https://bitbucket.org/jonforums/uru/src/master/
[rubyinstaller]: https://rubyinstaller.org/
[railsinstaller]: http://railsinstaller.org/
[rubystack]: http://bitnami.com/stack/ruby/installer
[sunfreeware]: http://www.sunfreeware.com
[openindiana]: http://openindiana.org/
[opensolaris-pkg]: http://opensolaris.org/os/project/pkg/
[gentoo-ruby]: http://www.gentoo.org/proj/en/prog_lang/ruby/
[freebsd-ruby]: https://wiki.freebsd.org/Ruby
[freebsd-ports-collection]: https://docs.freebsd.org/en/books/handbook/ports/#ports-using
[homebrew]: http://brew.sh/
[terminal]: https://en.wikipedia.org/wiki/List_of_terminal_emulators
[building-ruby]: https://github.com/ruby/ruby/blob/master/doc/contributing/building_ruby.md
[wsl]: https://learn.microsoft.com/zh-tw/windows/wsl/about
[asdf-vm]: https://asdf-vm.com/
[asdf-ruby]: https://github.com/asdf-vm/asdf-ruby
[openbsd-current-ruby-ports]: https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/lang/ruby/?only_with_tag=HEAD