29日目 Railsのインストール

Ruby on Railsを使う事になったので
`gem install rails` でインストールしてみました。

```ruby
$ gem install rails
Fetching: concurrent-ruby-1.1.5.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
```

さっそくエラー！

同じケース
https://teratail.com/questions/74708

```ruby
$ which ruby 
/usr/bin/ruby
$ which bundle
/usr/local/bin/bundle
```

rubyとbundleのパスが違うとエラーになるらしい。
先月rubyをインストールした時のログをみると、

```ruby
$ which ruby 
/Users/robamimim/.rbenv/shims/ruby
$ which bundle
/Users/robamimim/.rbenv/shims/bundle
```

あれれ？？？
なんでだろう・・・？

`.bash_profile`を確認。

```
15:45:38 ~ $ cat .bash_profile
# added by Anaconda3 5.3.0 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<
#eval "$(rbenv init -)"export PATH=$HOME/.nodebrew/current/bin:$PATH
export PATH=$HOME/.nodebrew/current/bin:$PATH
export NODEBREW_ROOT=/usr/local/var/nodebrew
export PATH=/usr/local/var/nodebrew/current/bin:$PATH
```

あれっ？？？
コメントアウトしている？なんでそうしたんだっけ。
思い出せないので、コメントを戻してソース。

```
15:45:48 ~ $ vi .bash_profile
15:46:57 ~ $ 
15:46:58 ~ $ 
15:46:58 ~ $ source ~/.bash_profile
-bash: eval: line 35: syntax error: unexpected end of file
15:47:15 ~ $ which ruby 
/Users/robamimim/.rbenv/shims/ruby
15:47:24 ~ $ which bundle
/Users/robamimim/.rbenv/shims/bundle
15:47:32 ~ $ 

```
OK、パス通った。
もう一度。


```
15:48:45 ~ $ gem install rails
Fetching: activesupport-5.2.3.gem (100%)
Successfully installed activesupport-5.2.3
Fetching: actionview-5.2.3.gem (100%)
Successfully installed actionview-5.2.3
Fetching: actionpack-5.2.3.gem (100%)
Successfully installed actionpack-5.2.3
Fetching: activemodel-5.2.3.gem (100%)
Successfully installed activemodel-5.2.3
Fetching: activerecord-5.2.3.gem (100%)
Successfully installed activerecord-5.2.3
Fetching: activejob-5.2.3.gem (100%)
Successfully installed activejob-5.2.3
Fetching: actionmailer-5.2.3.gem (100%)
Successfully installed actionmailer-5.2.3
Fetching: actioncable-5.2.3.gem (100%)
Successfully installed actioncable-5.2.3
Fetching: activestorage-5.2.3.gem (100%)
Successfully installed activestorage-5.2.3
Fetching: railties-5.2.3.gem (100%)
Successfully installed railties-5.2.3
Fetching: rails-5.2.3.gem (100%)
Successfully installed rails-5.2.3
Parsing documentation for activesupport-5.2.3
Installing ri documentation for activesupport-5.2.3
Parsing documentation for actionview-5.2.3
Installing ri documentation for actionview-5.2.3
Parsing documentation for actionpack-5.2.3
Installing ri documentation for actionpack-5.2.3
Parsing documentation for activemodel-5.2.3
Installing ri documentation for activemodel-5.2.3
Parsing documentation for activerecord-5.2.3
Installing ri documentation for activerecord-5.2.3
Parsing documentation for activejob-5.2.3
Installing ri documentation for activejob-5.2.3
Parsing documentation for actionmailer-5.2.3
Installing ri documentation for actionmailer-5.2.3
Parsing documentation for actioncable-5.2.3
Installing ri documentation for actioncable-5.2.3
Parsing documentation for activestorage-5.2.3
Installing ri documentation for activestorage-5.2.3
Parsing documentation for railties-5.2.3
Installing ri documentation for railties-5.2.3
Parsing documentation for rails-5.2.3
Installing ri documentation for rails-5.2.3
Done installing documentation for activesupport, actionview, actionpack, activemodel, activerecord, activejob, actionmailer, actioncable, activestorage, railties, rails after 25 seconds
11 gems installed
15:49:18 ~ $ 
```

できました！

しかし、ここからが本番なのでした・・・
（続く）
[29日目 その２ Ruby on Railsを起動したい！]
(https://qiita.com/robamimim/items/b087a45c6d0dd3f08c9c#rbenv-install-250-%E3%81%A7%E3%83%AD%E3%83%BC%E3%82%AB%E3%83%AB%E3%81%AE%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%E3%81%A8%E6%8F%83%E3%81%88%E3%81%A6%E3%81%BF%E3%82%88%E3%81%86)