Ruby Install Issues

TLDR: Terminal is telling me I have errors and to use “sudo” commands to install. Odin projects specifically states NOT to use sudo command unless Odin project specifies. Not sure what to do.

Hello! Making sure to follow the instructions provided for Mac here perfectly, I’m still encountering errors when installing the things needed to install Ruby.

The first issue I encounter is that, when installing xcode, I get this message:

xcode-select: error: command line tools are already installed, use “Software
Update” to install updates

Ignoring it and continuing on to the next step, Homebrew installed perfectly fine.

Step 2: installing Heroku is where I start seeing real issues:

sam@Mac-mini ~ % brew install heroku/brew/heroku

==> Tapping heroku/brew

Cloning into ‘/usr/local/Homebrew/Library/Taps/heroku/homebrew-brew’…

remote: Enumerating objects: 4, done.

remote: Counting objects: 100% (4/4), done.

remote: Compressing objects: 100% (4/4), done.

remote: Total 1619 (delta 0), reused 3 (delta 0), pack-reused 1615

Receiving objects: 100% (1619/1619), 211.90 KiB | 428.00 KiB/s, done.

Resolving deltas: 100% (396/396), done.

Tapped 2 formulae (30 files, 284.4KB).

Error: The following directories are not writable by your user:

/usr/local/share/zsh

/usr/local/share/zsh/site-functions

You should change the ownership of these directories to your user.

sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions

And make sure that your user has write permission.

chmod u+w /usr/local/share/zsh /usr/local/share/zsh/site-functions

On both the Heroku install and the next Step 3’s: “brew install rbenv” give me errors and tell me I should change permissions using a sudo command.

When trying the next step “rbenv init”, I receive this error:

zsh: command not found: rbenv

The instructions for installing via Odin Project specifically mention NOT to use any sudo commands unless the Odin projects specifies. I’m not sure what to do at this point and don’t want to use a sudo command and mess things up further.

Any help or advice would be greatly appreciated!

For future folks with the same issue:

Without any response,
I decided to follow the terminal’s suggested sudo commands and got everything working. :man_shrugging:t2:

The first error you’re getting is related to Homebrew permissions. In order for it to properly install software, it needs access to these directories

/usr/local/share/zsh

and

/usr/local/share/zsh/site-functions

Once you run the commands supplied in the error message, it should apply the proper permissions to those directories, and mostly prevent you from having to use sudo in the future.
If your using Homebrew to install rbenv. I’m going to assume that, the second error is due to rbenv installation failure caused by Homebrew. Once you fix the permissions, run

brew update

Once it’s done, run

brew doctor

Hopefully you’ll be greeted with a nice message saying

"Your system is ready to brew"

To fully understand the problem here, I’d highly recommend learning a bit about user and file permissions. Once you understand it a bit more, you’ll understand the high, yet justifiable, discouragement associated to the casual use of sudo

Here’s a very nice post about the topic.

Best luck. You got this!