PCを二台ひらいてrails導入をもういちど
別のPCでも作業できるようにしたくて、同じ環境を構築する。
こういう時ブログでログ取ってるとすごい楽だなーと痛感。
で。別の場所でメモってたrails導入あれこれ。
rvmを入れる
基本的には公式に従う。→RVM: Ruby Version Manager - Installing RVM
...gpg2が入ってないとのこと。以下参考に。qiita.com
$ brew install gpg2
けどこんなこと前入れた時にやったっけなー、、、とおもってプロに聞いたら以下回答。
Linux だと公開鍵のチェックがあるのですが、OSX だとスキップされるので公開鍵は入れてないです
(Docker とかでやるときは必要です)
とのことらしいので、公開鍵の部分は無視して進めてみる。
→ No public keyのエラーでちゃうじゃないの。
プロにもっかい聞いたら、
gpgがない場合は公開鍵の検証をスキップされますが、gpg入れちゃうと公開鍵の検証が走ってしまいます。
その場合は、公開鍵をrvm.ioの手順に沿って入れてください。
つまり中途半端にgpgなんて入れたもんだから、ちゃんとやらんといかん、ということでした。
エラー地獄
なんか昔プログラミングしようとして色々やった残骸が残っているのか、変なエラーがたくさんでた。
$ gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 ... $ curl -sSL https://get.rvm.io | bash -s stable --rails
エラー発生。 Requirements installation failed with status: 1. ってなんだこれ。stackoverflow.com
いろんな理由でエラーあるから具体的におk
だと…
ログを見ると
...
Updating system.....................................................................................................|
Installing required packages: autoconf, automake, pkg-config, libyaml, readline, openssl..........
Error running 'requirements_osx_brew_libs_install autoconf automake pkg-config libyaml readline openssl',
showing last 15 lines of /Users/masterkei/.rvm/log/1442389825_ruby-2.2.1/package_install_autoconf_automake_pkg-config_libyaml_readline_openssl.log
...
Try `brew tap --repair` and make sure `brew doctor` looks reasonable.
なんて書いてある。
とりあえず言われた通りにやってみる。
$ brew tap --repair $ brew doctor Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry and just ignore them. Thanks! Warning: Broken symlinks were found. Remove them with `brew prune`: /usr/local/share/doc/ruby Warning: You have unlinked kegs in your Cellar Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run `brew link` on these: ossp-uuid
なんかワーニング出た。とりあえず1つずつ潰していこう。
参考:Mac - homebrewとは何者か。仕組みについて調べてみた - Qiita
その1。
Warning: Broken symlinks were found. Remove them with `brew prune`: /usr/local/share/doc/ruby
言われるがままに `brew prune` を実行。(デッドリンクになっているものを削除するコマンドらすぃ)
$ brew prune Pruned 1 symbolic links and 2 directories from /usr/local
きえたっぽい。
その2。
Warning: You have unlinked kegs in your Cellar Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run `brew link` on these: ossp-uuid
おなじく言われるがままに`brew link`を実行(引数のパッケージを有効化するコマンドらすぃ)
$ brew link ossp-uuid Linking /usr/local/Cellar/ossp-uuid/1.6.2... 8 symlinks created
できたっぽい。
気を取り直して
$ curl -sSL https://get.rvm.io | bash -s stable --rails
今度はうまくうごきました。
rvmの設定とかrubyもっかい入れたりとか
なんかインストール中にまたエラー出たけど大丈夫かこれ。
やっぱrailsインスコ中になんかエラーはいてるな。rubyのインストールミスってるっぽい。
まぁとりあえずrvmはインストールできてるし、後でもっかいインストールすればいいか。
$ rvm list known
rvm無いっていわれる。くそが
ターミナル再起動したらいけタワー
で、とりあえずrvmが最新かを確認
$ rvm get head $ rvm get latest
以下の行を .bashrc に追記。(※ ~/ 直下の「.rvm」に作成されたスクリプトを読み込む設定)
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting # RVM追記 [ -s ${HOME}/.rvm/scripts/rvm ] && source ${HOME}/.rvm/scripts/rvm
…なんかすでに書き込まれてない?
と思ったけどまあいいや。
.bashrcを再読み込み。
$ source ~/.bash_profile
rubyをインストール。
$ rvm install ruby-2.2.2
時間かかるなー。