Skip to content

Instantly share code, notes, and snippets.

@satococoa
Last active June 5, 2016 03:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save satococoa/5830035 to your computer and use it in GitHub Desktop.
Save satococoa/5830035 to your computer and use it in GitHub Desktop.
Mac OS X 上での Homebrew + rbenv + ruby-build + ruby + rails の環境構築(Xcode, Comamnd Line Tools のインストールを済ませてから。)
# Homebrew のインストール
# 公式 (http://brew.sh/) に載っているコマンドです
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Ruby のビルドに必要なものをインストール
brew install openssl readline rbenv ruby-build # 時間がかかります
# rbenv 用の設定を .bash_profile に書き込む
echo 'export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl) --with-readline-dir=$(brew --prefix readline) $RUBY_CONFIGURE_OPTS"' >> ~/.bash_profile
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
# bash の設定を読み込む (または、一回ターミナルを終了させてもう一度開く)
source ~/.bash_profile
# ruby 2.2.3 のインストール
rbenv install 2.2.3
rbenv global 2.2.3
# ruby がちゃんと入ったことを確認
ruby -v
# => ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
# rails インストール
gem install rails --no-ri --no-rdoc # --no-ri, --no-rdoc はドキュメントのインストールをスキップするオプション (時間がかかるので)
rbenv rehash # rbenv を使っている場合、gem install 後にはこれが必要
rails -v
# => Rails 4.2.4
@a2ikm
Copy link

a2ikm commented Jun 21, 2013

vim ~/.bash_profileのあたり、次のようにechoで自動化してもよいのかと。
あとパスはbrew --prefix ライブラリ名でとるようにしてみました。

echo 'export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl) --with-readline-dir=$(brew --prefix readline) $RUBY_CONFIGURE_OPTS"' >> ~/.bash_profile
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi'

@moritamoriko
Copy link

できましたー!

@satococoa
Copy link
Author

@a2ikm
ありがとうございますー!
そっちのやり方の方がいいですね
後で更新します。

@satococoa
Copy link
Author

更新しました。
これでこのスクリプトを流すだけでセットアップ完了するはず!

@satococoa
Copy link
Author

$ irb
> puts 'こんにちは'
> require 'openssl'
> require 'open-uri'
> open('https://www.google.com/').read

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment