Ubuntu Ruby on Rails環境の構成

3730 ワード

徳に欠ける
手順1-RVM(Ruby Version Manager)のインストール
rubyのバージョン管理ツールのインストール
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ curl -sSL https://get.rvm.io | bash -s stable

RVM環境のロード
$ source /home/.rvm/scripts/rvm

変更元はRuby Chinaミラー
echo "ruby_url=https://cache.ruby-china.org/pub/ruby" > ~/.rvm/user/db

インストールに成功したかどうかを確認
$ rvm -v
rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

手順2-指定されたバージョンRuby環境をRVMでインストールする
$ rvm requirements
$ rvm install 2.5.0

rvmリストにRubyが正しくインストールされているかどうかを確認します.
$ rvm list
rvm rubies

 * ruby-2.4.0 [ x86_64 ]
=> ruby-2.5.0 [ x86_64 ]

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

手順3-Rubyバージョンの設定
システムの現在のデフォルトRubyバージョンの設定
$ rvm use 2.5.0 --default

環境が正しく構成されているかどうかを確認します.
$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]

$ gem -v
2.7.3


gemソースをRuby Chinaミラーに設定
$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/

Bundlerのインストール
$ gem install bundler

インストールに成功したかどうかを確認
$ bundler -v 
Bundler version 1.16.2

手順4-Railsのインストール
最終取付Rails
$ gem install rails

インストールに成功したかどうかを確認
$ rails -v    
Rails 5.2.0

RVMのインストール時に発生する可能性のある問題
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ curl -sSL https://get.rvm.io | bash -s stable

or
$ curl -L https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
$ chown -R $(whoami) ~/.gnupg/

Problem description
crystal@crystal:~$ \curl -sSL https://get.rvm.io | bash -s stable
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
gpg: Signature made Mon Sep 11 04:59:21 2017 CST using RSA key ID BF04FF17
gpg: Fatal: can't open '/home/crystal/.gnupg/trustdb.gpg': Permission denied
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/crystal/.rvm/archives/rvm-1.29.3.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc'! Try to install GPG v2 and then fetch the public key:

    gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

or if it fails:

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

the key can be compared with:

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

NOTE: GPG version 2.1.17 have a bug which cause failures during fetching keys from remote server. Please downgrade or upgrade to newer version (if available) or use the second method described above.
$ curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
$ source /home/crystal/.rvm/scripts/rvm

現存する問題.
RVMによるruby 2.3.0のインストールで発生した問題
Error running '__rvm_make -j4', please read/home/wayne/.rvm/log/1529486866_ruby-2.3.0/make.log There has been an error while running make. Halting the installation.
参考資料
https://ruby-china.org/wiki/install_ruby_guide