5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rbenvでrubyをインストールするシェルスクリプト

Posted at

環境はUbuntu14.04ですが、いじれば別のOS、シェルでも使えるはず。

libsqlite3-devを入れているのはrails用なので必要ない場合は消してください。

gemはbundler、pry、pry-docを入れているのでこちらも必要ない場合は消してください。

#!/bin/bash

echo "install rbenv and ruby"

# 必要なライブラリをインストール
sudo apt-get install -y libreadline-dev libssl-dev libsqlite3-dev

# rbenvとプラグインを配置
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
mkdir ~/.rbenv/plugins
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

# rbenvの設定
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc

# rubyとgemのインストール
bash -lc "
rbenv install 2.2.3
rbenv global 2.2.3
gem install bundler pry pry-doc
"

bash -lcとしているのはsource ~/.bashrcとしても~/.bashrcが反映されない(別シェルで起動するらしい)ので。

参考 Ansibleでシェル設定の再読み込みが必要になった場合の対応 - Qiita

5
4
0

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
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?