I am trying to install iStats via a ruby gem.

First I ran the command:

xcode-select --install and the output was:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates. So that was okay.

Then I ran:

sudo gem install iStats

and the output was:

Building native extensions.  This could take a while...
ERROR:  Error installing iStats:
ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.3.0/gems/iStats-1.6.1/ext/osx_stats
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20190117-44665-taivle.rb extconf.rb
creating Makefile

current directory: /Library/Ruby/Gems/2.3.0/gems/iStats-1.6.1/ext/osx_stats
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.3.0/gems/iStats-1.6.1/ext/osx_stats
make "DESTDIR="
make: *** No rule to make target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin16/ruby/config.h', needed by `smc.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/iStats-1.6.1 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-16/2.3.0/iStats-1.6.1/gem_make.out

I'm not sure what all of this means, but I know it did not work. So I tried installing ruby using:

brew install ruby, which seemed to do its job.

Then I tried the sudo gem command again but I got the same output as above.

What is going wrong here?


I just read https://stackoverflow.com/a/26600110/6678549 and tried this:

sudo gem update --system and got this output:

Updating rubygems-update
Successfully installed rubygems-update-3.0.2
Parsing documentation for rubygems-update-3.0.2
Installing darkfish documentation for rubygems-update-3.0.2
Done installing documentation for rubygems-update after 108 seconds
Parsing documentation for rubygems-update-3.0.2
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.0.2
ERROR:  While executing gem ... (Errno::EPERM)
Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem

So it almost worked, but I'm still no closer to installing iStats.


My ruby version is ruby 2.3.7p456 in case it is relevant and I am using MacOS Sierra. I have done a bit of reading and found about System Integrity Protection. I have tried a few other commands like sudo gem install iStats -n /usr/local/bin, but still nothing works. Although after runningsudo gem update --system` it now says the latest version is already installed.


I have done it!

I am not sure exactly what I did right, but I used these two commands:

export LDFLAGS="-L/usr/local/opt/ruby/lib"

export CPPFLAGS="-I/usr/local/opt/ruby/include"

Then I tried:

sudo gem install iStats


sudo gem install iStats -n /usr/local/bin

Now I have successfully installed iStats 1.6.1.

Strangely though, I used those two export commands earlier on and they did not do the trick. So something must have changed in the meantime, I don't know what it is.

  • 1
    Note that I recommend against messing with the system Ruby and instead installing rbenv: github.com/rbenv/rbenv – this should make your life easier, and you don't need to run sudo for anything. – slhck Jan 17 '19 at 15:52
  • @slhck Thanks for the advice, I'll keep that in mind in the future. – AkThao Jan 17 '19 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.