Ruby和Rails开发环境安装

时间:2023-12-16 16:20:02
  • 更新包管理

    sudo apt-get update

  • 安装curl

    sudo apt-get install curl

*安装rvm via curl

\curl -L https://get.rvm.io | bash -s stable --ruby

报错:

greenc@Inspiron-M5110:~$ \curl -L https://get.rvm.io | bash -s stable --ruby

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 184 100 184 0 0 82 0 0:00:02 0:00:02 --:--:-- 82

100 22721 100 22721 0 0 7991 0 0:00:02 0:00:02 --:--:-- 62592

Downloading https://github.com/rvm/rvm/archive/1.26.11.tar.gz

^[[BDownloading https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc

gpg: 已创建目录‘/home/greenc/.gnupg’

gpg: 新的配置文件‘/home/greenc/.gnupg/gpg.conf’已建立

gpg: 警告:在‘/home/greenc/.gnupg/gpg.conf’里的选项于此次运行期间未被使用

gpg: 钥匙环‘/home/greenc/.gnupg/pubring.gpg’已建立

gpg: 于 2015年03月31日 星期二 05时52分13秒 CST 创建的签名,使用 RSA,钥匙号 BF04FF17

gpg: 无法检查签名:找不到公钥

Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found.

Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).

GPG signature verification failed for '/home/greenc/.rvm/archives/rvm-1.26.11.tgz' - 'https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc'!

try downloading the signatures:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

or if it fails:

command curl -sSL https://rvm.io/mpapis.asc | gpg --import -

the key can be compared with:

https://rvm.io/mpapis.asc
https://keybase.io/mpapis

解决办法:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
  • 继续安装

    source ~/.bashrc

    $ source ~/.bash_profile

  • 检查版本

    rvm -v

rvm 1.26.11 (latest) by Wayne E. Seguin wayneeseguin@gmail.com, Michal Papis mpapis@gmail.com [https://rvm.io/]

*安装ruby

rvm install 2.2.0

install 后面跟的是版本号,可以使用rvm list known 来查看有哪些版本。

漫长的等待........

检查版本

ruby -v

以上已经总结了我个人遇到的问题,和解决方案。如果一路下来没有问题,恭喜你,已经成功搭建了ruby环境。

安装bunlder

gem install bunlder
  • 安装rails

    gem install rails

  • 验证

    rails -v