如何安装Ruby和RubyGems

Python014

如何安装Ruby和RubyGems,第1张

下载并安装Ruby Installer for Windows.安装程序已经包含了RubyGems。

请确保当你安装和使用vmc时候使用带Ruby功能的命令提示符窗口,从Windows的“开始”菜单中的“所有程序”→“Ruby<VERSION>→启动命令提示符使用Ruby"。

最后,从Ruby命令提示符更新RubyGems

prompt>gem update --system

Windows Gemfiles支持

一旦你安装了Ruby,你可以按照说明来部署app和使用Gemfile,部署Ruby应用到Cloud Foundry

Windows用户要注意以下几点:

当Windows机器上生成Gemfile.lock文件,它往往包含与Windows匹配特定版本的gems,例如mysql2,thin,PG含有“-X86-mingw32的”的后缀。

例如,在Windows机器上运行包安装用的Gemfile,看起来像这样:

gem 'sinatra'

gem 'mysql2'

gem 'json'

结果是Gemfile.lock看起来如下:

GEMremote: http://rubygems.org/specs: json (1.7.3) mysql2 (0.3.11-x86-mingw32) rack (1.4.1) rack-protection (1.2.0)rack sinatra (1.3.2)rack (~>1.3, >= 1.3.6)rack-protection (~>1.2)tilt (~>1.3, >= 1.3.3) tilt (1.3.3)PLATFORMSx86-mingw32DEPENDENCIESjsonmysql2sinatra

Cloud Foundry能够正确地安装这些gems,而不需要修改你的Gemfile.lock

RedHat/Fedora

打开终端,使用yum命令行工具来安装Ruby和RubyGems,如下所示

安装Ruby:

prompt$ sudo yum install ruby

如果您使用的是企业Linux RedHat 6,开启可选通道Red Hat Network (RHN).

安装RubyGems:

prompt$ sudo yum install rubygems

Centos

打开终端,使用yum命令行工具来安装Ruby和RubyGems,如下所示

安装基本的包:

prompt$ yum install -y ruby

安装额外的Ruby包和文档:

prompt$ yum install -y ruby-devel ruby-docs ruby-ri ruby-rdoc

安装RubyGems:

prompt$ yum install -y rubygems

SuSE

打开终端,使用yast 命令行工具来安装Ruby和RubyGems,如下所示

安装Ruby:

prompt$ yast -i ruby

安装RubyGems:

prompt$ yast -i rubygems

Debian

You use Ruby Version Manager (rvm) to install Ruby and RubyGems on Debian. The following procedure shows how to install rvm if you have not already done so.

Use the following apt-get command-line tool to install the required packages:

prompt$ sudo apt-get install gcccurl git-core build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev

Run the bash script to install rvm from Ruby Version Manager.

prompt$ bash <<curl -s https://rvm.beginrescueend.com/install/rvm

Edit your ~/.bashrc file as described by the RVM installation in the precding step.

Use rvm to install Ruby and RubyGems as shown:

prompt$ rvm package install zlib

prompt$ rvm install 1.9.2 -C --with-zlib-dir=$rvm_path/usr

prompt$ rvm use 1.9.2

1、安装ruby前一般需要安装rvm或其他ruby版本管理器

2、使用rvm安装ruby,并指定默认的ruby版本,如果是mac机器,则默认安装了ruby2.0

详情看ruby-china的官方