2019年10月17日 星期四

升級至 macOS Catalina 之後,iStats 無法使用

$ istats 
-bash: /usr/local/bin/istats: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory

看起來找不到 macOS 自帶的 ruby 2.3,看到這邊其實就曉得當初沒有正確使用 Homebrew 的 ruby 安裝 iStats。


我們依然可以先檢查一下 istats 裡面寫些什麼:

$ which istats
/usr/local/bin/istats

$ grc ls -al /usr/local/bin/istats
-rwxr-xr-x  1 root  admin  523 10 13 22:35 /usr/local/bin/istats

$ cat /usr/local/bin/istats
#!/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'iStats' is installed as part of a gem, and
# this file is here to facilitate running it.



再檢查一下 ruby 版本資訊

$ grc ls -al /System/Library/Frameworks/Ruby.framework/Versions
total 0
drwxr-xr-x  4 root  wheel  128 10 17 01:21 .
drwxr-xr-x  5 root  wheel  160 10 17 01:21 ..
drwxr-xr-x  6 root  wheel  192 10 13 07:21 2.6
lrwxr-xr-x  1 root  wheel    3 10 17 01:17 Current -> 2.6

$ which ruby
/usr/bin/ruby

$ ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]

$ which gem
/usr/bin/gem

$ gem --version
3.0.3



重新安裝 iStats 吧,首先來健康檢查一下 Homebrew

$ 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 or file an issue; just ignore this. Thanks!

Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so:
  echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile

Warning: Your Xcode is configured with an invalid path.
You should change it to the correct path:
  sudo xcode-select -switch /Applications/Xcode.app



總之醫生怎麼說、我們就怎麼做 (( 被揍

echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
$ sudo xcode-select -switch /Applications/Xcode.app

$ 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 or file an issue; just ignore this. Thanks!

Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so:
  echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile



對,別忘了寫進 ~/.bash_profile 的內容不會馬上生效,多補一行指令

$ export PATH="/usr/local/sbin:$PATH"
$ brew doctor
Your system is ready to brew.



另外,透過 Homebrew 安裝 ruby 時有提到:

By default, binaries installed by gem will be placed into:
  /usr/local/lib/ruby/gems/2.6.0/bin

You may want to add this to your PATH.

If you need to have ruby first in your PATH run:
  echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile



所以照做:

$ echo 'export PATH="/usr/local/lib/ruby/gems/2.6.0/bin:$PATH"' >> ~/.bash_profile
$ export PATH="/usr/local/lib/ruby/gems/2.6.0/bin:$PATH"

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
export PATH="/usr/local/opt/ruby/bin:$PATH"



然後再次檢查 ruby 版本資訊

$ which ruby
/usr/local/opt/ruby/bin/ruby

$ ruby --version
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]

$ which gem
/usr/local/opt/ruby/bin/gem

$ gem --version
3.0.6



「您現在可以放心安裝 iStats 」

$ gem install iStats
Building native extensions. This could take a while...
Successfully installed iStats-1.6.1
Parsing documentation for iStats-1.6.1
Installing ri documentation for iStats-1.6.1
Done installing documentation for iStats after 0 seconds
1 gem installed




「您現在可以放心使用 iStats 」

$ which istats
/usr/local/lib/ruby/gems/2.6.0/bin/istats

$ istats --version

iStats v1.6.1

$ istats scan

Scanning keys...



Done scanning keys.

All keys are disabled by default. Use `istats enable [key]` to enable specific keys or `istats enable all`.

The enabled sensors will show up when running `istats` or `istats extra`.



$ istats enable all

$ istats
--- CPU Stats ---
CPU temp:               40.0°C      ▁▂▃▅▆▇

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

--- Battery Stats ---
Battery health:         good     
Cycle count:            4           ▁▂▃▅▆▇  0.4%
Max cycles:             1000        
Current charge:         4417 mAh    ▁▂▃▅▆▇  100%
Maximum charge:         4426 mAh    ▁▂▃▅▆▇  101.0%
Design capacity:        4381 mAh    
Battery temp:           33.3°C      

--- Extra Stats ---
Tm0P Unknown temp:      35.25°C     ▁▂▃▅▆▇
Ts0P Palm rest L temp:  26.88°C     ▁▂▃▅▆▇
Ts0S Memory Bank Proximity temp: 32.3°C      ▁▂▃▅▆▇
Ts1P Unknown temp:      27.88°C     ▁▂▃▅▆▇
Ts1S Unknown temp:      34.48°C     ▁▂▃▅▆▇
TA0V Unknown temp:      28.11°C     ▁▂▃▅▆▇
TB0T Battery TS_MAX temp: 33.3°C      ▁▂▃▅▆▇
TB1T Battery 1 temp:    33.3°C      ▁▂▃▅▆▇
TB2T Battery 2 temp:    30.39°C     ▁▂▃▅▆▇
TCaP Unknown temp:      36.44°C     ▁▂▃▅▆▇
TCGC PECI GPU temp:     42.0°C      ▁▂▃▅▆▇
TCHP Unknown temp:      37.0°C      ▁▂▃▅▆▇
TCMX Unknown temp:      43.11°C     ▁▂▃▅▆▇
TCSA PECI SA temp:      42.0°C      ▁▂▃▅▆▇
TCXC PECI CPU temp:     43.11°C     ▁▂▃▅▆▇
TC0E CPU 0 ?? temp:     45.28°C     ▁▂▃▅▆▇
TC0F CPU 0 ?? temp:     47.13°C     ▁▂▃▅▆▇
TC0P CPU 0 Proximity temp: 40.0°C      ▁▂▃▅▆▇
TC1C Core 1 temp:       41.0°C      ▁▂▃▅▆▇
TC2C Core 2 temp:       42.0°C      ▁▂▃▅▆▇
TH0a Unknown temp:      31.75°C     ▁▂▃▅▆▇
TH0F Unknown temp:      31.67°C     ▁▂▃▅▆▇
TM0P Memory Slot Proximity temp: 38.56°C     ▁▂▃▅▆▇
TPCD Platform Controller Hub Die temp: 39.0°C      ▁▂▃▅▆▇
TSMP Unknown temp:      33.5°C      ▁▂▃▅▆▇
TUDD Unknown temp:      32.06°C     ▁▂▃▅▆▇
TW0P AirPort Proximity temp: 37.75°C     ▁▂▃▅▆▇



參考資料


沒有留言: