Ruby
Mac
homebrew
Gem

iStats のインストールに失敗するので、 gem と homebrew と ruby をアップデートした

ruby gem の iStats をインストールしようとすると、エラーが出てインストールに失敗した。
なので、gem と homebrew と ruby をアップデートしたらインストールできたという試行錯誤のログ.
多分 ruby は、アップデートしなくても良かったと思う。

#####################
# iStats のインストール(失敗)
#####################

MacBook-Air:~ hoge$ gem install iStats
Fetching: sparkr-0.4.1.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
MacBook-Air:~ hoge$ sudo gem install iStats
Password:
Fetching: sparkr-0.4.1.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.

#####################
# gem のアップデート(失敗)
#####################

MacBook-Air:~ hoge$ which gem
/usr/bin/gem

# gem のバージョンを確認 
MacBook-Air:~ hoge$ gem -v
2.5.2

# gem のアップデート
MacBook-Air:~ hoge$ sudo gem update --system
Password:
Updating rubygems-update
Fetching: rubygems-update-2.7.4.gem (100%)
Successfully installed rubygems-update-2.7.4
Parsing documentation for rubygems-update-2.7.4
Installing ri documentation for rubygems-update-2.7.4
Installing darkfish documentation for rubygems-update-2.7.4
Done installing documentation for rubygems-update after 73 seconds
Parsing documentation for rubygems-update-2.7.4
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 2.7.4
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem
MacBook-Air:~ hoge$ gem list --user-install
ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --user-install

#####################
# brew のアップデート(成功)
#####################

MacBook-Air:~ hoge$ brew --version
Homebrew 1.3.9
Homebrew/homebrew-core (git revision 2dfc; last commit 2017-12-07)

MacBook-Air:~ hoge$ brew update
To restore the stashed changes to /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core run:
  'cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git stash pop'
Updated 1 tap (homebrew/core).

(すごく長いので省略)

gcc@4.7                          jetty@8                          open-mpi@1.6                     zeromq@4.1

MacBook-Air:~ hoge$ brew --version
Homebrew 1.5.2
Homebrew/homebrew-core (git revision d789; last commit 2018-01-26)


#####################
# gem のアップデート(成功)
#####################

MacBook-Air:~ hoge$ gem update --system
Latest version already installed. Done.

MacBook-Air:~ hoge$ gem -v
2.7.4

#####################
# ruby のアップデート
#####################
MacBook-Air:~ hoge$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]

MacBook-Air:~ hoge$ which ruby
/usr/bin/ruby

MacBook-Air:~ hoge$ brew install rbenv

(省略)

MacBook-Air:~ hoge$ rbenv -v
rbenv 1.1.1

# 最新の ruby を調べる
MacBook-Air:~ hoge$ rbenv install --list

MacBook-Air:~ hoge$ rbenv install 2.5.0
ruby-build: use openssl from homebrew
Downloading ruby-2.5.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.bz2

MacBook-Air:~ hoge$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]


# .bash_profile に以下を追加
# if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

MacBook-Air:~ hoge$ vim ~/.bash_profile
MacBook-Air:~ hoge$ source ~/.bash_profile 

MacBook-Air:~ hoge$ which ruby
/Users/hoge/.rbenv/shims/ruby
MacBook-Air:~ hoge$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

#####################
# iStats のアップデート(成功)
#####################

MacBook-Air:~ hoge$ gem install iStats
Fetching: sparkr-0.4.1.gem (100%)
Successfully installed sparkr-0.4.1
Fetching: parseconfig-1.0.8.gem (100%)
Successfully installed parseconfig-1.0.8
Fetching: iStats-1.5.2.gem (100%)
Building native extensions. This could take a while...
Successfully installed iStats-1.5.2
Parsing documentation for sparkr-0.4.1
Installing ri documentation for sparkr-0.4.1
Parsing documentation for parseconfig-1.0.8
Installing ri documentation for parseconfig-1.0.8
Parsing documentation for iStats-1.5.2
Installing ri documentation for iStats-1.5.2
Done installing documentation for sparkr, parseconfig, iStats after 0 seconds
3 gems installed

#####################

MacBook-Air:~ hoge$ istats
--- CPU Stats ---
CPU temp:               50.5°C      ▁▂▃▅▆▇

--- Fan Stats ---
Total fans in system:   1           
Fan 0 speed:            2001 RPM    ▁▂▃▅▆▇

--- Battery Stats ---
Battery health:         Check Battery
Cycle count:            768         ▁▂▃▅▆▇  76.8%
Max cycles:             1000        
Current charge:         0 mAh       ▁▂▃▅▆▇  -2147483648%
Maximum charge:         0 mAh       ▁▂▃▅▆▇  0.0%
Design capacity:        6700 mAh    
Battery temp:           33.19°C     

For more stats run `istats extra` and follow the instructions.
MacBook-Air:~ hoge$