macOS – Command ‘istats’ Not Found After ‘gem install iStats’

command lineinstallmacosterminal

I wanted to use iStats in command line/terminal mode, so I did the following:

  • I installed iStats with the command gem install iStats as per this answer to an AskDifferent question;
  • However, when I issue the command istats I get a -bash: istats: command not found;
  • Issuing the command gem list shows me that iStats is installed (*** LOCAL GEMS *** and in second position it reads iStats (1.6.1);
  • I checked and the app resides in /usr/local/lib/ruby/gems/2.6.0/gems/;
  • Issuing a gem environment command shows the following - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.6.0;
  • I uninstalled the Gem by issuing gem uninstall iStats;
  • Then issuing gem list shows that the app was indeed removed;
  • Then I issued gem install iStats that gave the following output:

    Fetching iStats-1.6.1.gem
    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
  • Issuing istats command gives again -bash: istats: command not found.

Any ideas?


System used (just in case):

  • macOS Mojave Version 10.14.5
  • Ruby version: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
  • MacBook Pro (13-inch, 2018, Four Thunderbolt 3 Ports)
  • Processor: 2.7 GHz Intel Core i7
  • Memory: 16 GB 2133 MHz LPDDR3
  • Graphics: Intel Iris Plus Graphics 655 1536 MB

Best Answer

Thanks to historystamp's comment here is how the problem was solved (for bash shell):

  1. Open/Launch Terminal
  2. gem uninstall iStats (source)
  3. gem install iStats --user-install (source)
  4. export PATH="~/.gem/ruby/2.6.0/bin:$PATH" (source)
  5. source ~/.bash_profile (source)
  6. istats

If you use macOS Catalina, the default shell is zsh. The adapted instructions are the following:

  1. Open/Launch Terminal
  2. gem uninstall iStats (source)
  3. gem install iStats --user-install (source)
  4. Open or create ~/.zshrc
  5. At the end of the file (or where appropriate) insert: export PATH=~/.gem/ruby/2.6.0/bin:$PATH (source)
  6. Save file ~/.zshrc
  7. Source the .zshrc file: . ~/.zshrc (source)
  8. istats