RVMでRubyをインストールしてみた
こんにちは、KUJIRAです。今更ながらchefを勉強しようと思いまして、急遽Rubyを自分の持っている開発環境(CentOS)にインストールしてみました。Rubyのインストールは普通にCentOSのパッケージにあるのですが、バージョンがちょっとイケてなかったり、過去のものと切り替えて使ったりしたかったのでそういう管理ツールのRVMをインストールすることにしました。なので今日は、RVMをインストールしてRubyをインストールするところまでやります。
- RVMのインストール
- Rubyのインストール
RVMのインストール
まずはRVMをインストールします。RVMのインストールは以下のコマンドを実行することでできます。
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 $ curl -sSL https://get.rvm.io | bash -s stable $
これでRVMはインストール完了です。ただ、時々こんなことを聞かれる人がいるみたいなので、
Upgrade Notes: * WARNING: You have '~/.profile' file, you might want to load it, to do that add the following line to '/home/foo/.bash_profile': source ~/.profile * No new notes to display.
そうした時には注意されていることに従って対応してください。
$ echo "source ~/.profile" >> ~/.bash_profile $ .
これでRVMがインストールできました。試しに動かしてみましょう。
$ rvm --help Usage: ruby [switches] [--] [programfile] [arguments] -0[octal] specify record separator (\0, if no argument) -a autosplit mode with -n or -p (splits $_ into $F) -c check syntax only -Cdirectory cd to directory before executing your script -d, --debug set debugging flags (set $DEBUG to true) -e 'command' one line of script. Several -e's allowed. Omit [programfile] -Eex[:in], --encoding=ex[:in] specify the default external and internal character encodings -Fpattern split() pattern for autosplit (-a) -i[extension] edit ARGV files in place (make backup if extension supplied) -Idirectory specify $LOAD_PATH directory (may be used more than once) -l enable line ending processing -n assume 'while gets(); ... end' loop around your script -p assume loop like -n but print line also like sed -rlibrary require the library before executing your script -s enable some switch parsing for switches after script name -S look for the script using PATH environment variable -T[level=1] turn on tainting checks -v, --verbose print version number, then turn on verbose mode -w turn warnings on for your script -W[level=2] set warning level; 0=silence, 1=medium, 2=verbose -x[directory] strip off text before #!ruby line and perhaps cd to directory --copyright print the copyright --enable=feature[,...], --disable=feature[,...] enable or disable features --external-encoding=encoding, --internal-encoding=encoding specify the default external or internal character encoding --version print the version --help show this message, -h for short message Features: gems rubygems (default: enabled) rubyopt RUBYOPT environment variable (default: enabled) $
このようなヘルプメッセージが表示されない場合は、インストールができていないため何が問題かを把握しインストールしなおしてください。
RVMのインストール
次にRubyをインストールします。以下のコマンドを実行してください。
$ rvm install ruby-2.2.0 --default Searching for binary rubies, this might take some time. No binary rubies available for: centos/7/x86_64/ruby-2.2.0. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for centos. Installing requirements for centos. Installing required packages: libyaml-devel, readline-devel, zlib-devel, libffi-devel, openssl-devel, sqlite-devel............... Requirements installation successful. Installing Ruby from source to: /home/KUJIRA/.rvm/rubies/ruby-2.2.0, this may take a while depending on your cpu(s)... ruby-2.2.0 - #downloading ruby-2.2.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 12.6M 100 12.6M 0 0 2395k 0 0:00:05 0:00:05 --:--:-- 2792k ruby-2.2.0 - #extracting ruby-2.2.0 to /home/KUJIRA/.rvm/src/ruby-2.2.0.... ruby-2.2.0 - #applying patch /home/KUJIRA/.rvm/patches/ruby/2.2.0/fix_installing_bundled_gems.patch. ruby-2.2.0 - #configuring......................................................... ruby-2.2.0 - #post-configuration.. ruby-2.2.0 - #compiling............................................................................... ruby-2.2.0 - #installing............................. ruby-2.2.0 - #making binaries executable.. ruby-2.2.0 - #downloading rubygems-2.4.6 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 437k 100 437k 0 0 332k 0 0:00:01 0:00:01 --:--:-- 332k No checksum for downloaded archive, recording checksum in user configuration. ruby-2.2.0 - #extracting rubygems-2.4.6.... ruby-2.2.0 - #removing old rubygems......... ruby-2.2.0 - #installing rubygems-2.4.6..................... ruby-2.2.0 - #gemset created /home/KUJIRA/.rvm/gems/ruby-2.2.0@global ruby-2.2.0 - #importing gemset /home/KUJIRA/.rvm/gemsets/global.gems........................................................... ruby-2.2.0 - #generating global wrappers........ ruby-2.2.0 - #gemset created /home/KUJIRA/.rvm/gems/ruby-2.2.0 ruby-2.2.0 - #importing gemsetfile /home/KUJIRA/.rvm/gemsets/default.gems evaluated to empty gem list ruby-2.2.0 - #generating default wrappers........ ruby-2.2.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake). Install of ruby-2.2.0 - #complete Ruby was built without documentation, to build it run: rvm docs generate-ri $
インストールが完了したらこちらも動作確認をしてみましょう。
$ ruby --version ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux] $
これで一通り今日の目標は達成しました。結構雑でしたが、こんなものでしょう・・・KUJIRAでした。