I am a Windows user and just got the new MacBook Pro with the latest OS updates. I wanted to install one tool in which it was mentioned to install run $ gem install iStats

which gives me an error

$ ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
nitin_mac@Nitins-MBP ~ % 

I am not sure how to get permission; if I run $ su, it asks for a password even if I am entering the correct one it still gives me an error

$ su:sorry

nitin_mac@Nitins-MBP ~ % su
su: Sorry

1 Answer 1


The quick answer is if something tells you to use su it is probably wrong unless you fully understand why you are using it.

In this case ruby is set up so that gems are written to a directory /Library/Ruby/Gems/2.6.0 that needs root permissions to write to. Thus you get the first error.

You can install the gem by running

sudo gem install iStats

You will be prompted for your own password (su prompts you for the password of the user you are changing to which without any other arguments is root - which on macOS by default does not have one and you cannot use root. Which explains why you could not provide the password for su as you don't know it.)

I would note that if you are doing much Ruby work you should look at rbenv or similar to allow gems to be installed without sudo and allow different gems for different projects.

  • Usually if the instructions tell you to use sudo, they're probably wrong (again) if you don't understand why. A decent reference is moncefbelyamani.com/… Dec 29, 2021 at 20:53
  • In this case sudo is correct as /Library/Ruby is not a user specific path - but for all users on the path (@MarcWilson Your comment could be read in a couple of ways if you are saying I should say use su or sudo - or if you are saying sudo is wrong here)
    – mmmmmm
    Dec 29, 2021 at 20:58
  • The path doesn't have anything to do with whether or not sudo is the correct thing to use. I'm saying that you should not be installing into system paths. There is no reason to. You should not depend on the system Ruby even being there for much longer. Dec 29, 2021 at 23:41
  • @MarcWilson So what is the correct way to install Ruby gems?
    – mmmmmm
    Dec 30, 2021 at 10:30
  • Hence the link I provided, which provides good detail. Dec 30, 2021 at 17:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .