LoginSignup
21
20

More than 5 years have passed since last update.

Raspberry PiにRuby 2.1.5を入れてみた

Posted at

Raspberry Pi+Raspbianの環境に、新しいRubyを入れています。

$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)"

$ uname -a
Linux raspberrypi 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l GNU/Linux

$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [arm-linux-eabihf]

準備

Rubyのバージョンを切り替えるrbenvを入れます。

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile

インストールできるバージョンを調べる。

$ rbenv install --list
Available versions:
  1.8.6-p383
  1.8.6-p420
(略)
  2.1.3
  2.1.4
  2.1.5
(略)

Ruby 2.1.5のインストール

頭にtimeがついているのは処理時間を計測するためです。本来は不要。

$ time rbenv install 2.1.5
Downloading ruby-2.1.5.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/4305cc6ceb094df55210d83548dcbeb5117d74eea25196a9b14fa268d354b100
Installing ruby-2.1.5...
Installed ruby-2.1.5 to /home/pi/.rbenv/versions/2.1.5


real    137m34.468s
user    128m43.180s
sys 4m34.110s

2時間強かかりました。

バージョン切替

$ rbenv versions
* system (set by /home/pi/.rbenv/version)
  2.1.5

ちゃんと2.1.5が入ってますね。

$ rbenv global 2.1.5
$ rbenv rehash
$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [armv6l-linux-eabihf]

でけた!

21
20
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
20